From 1d9ce94f968440e2ca7867406e803c2a18662da4 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Sat, 3 Dec 2022 11:51:15 +0100 Subject: Add support for some additional keys in interactive mode (#634) * Ignore tab key in interactive mode * Support home and end keys in interactive mode * Support delete key in interactive mode --- src/command/client/search/cursor.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/command/client/search/cursor.rs') diff --git a/src/command/client/search/cursor.rs b/src/command/client/search/cursor.rs index da2be45e..827242c8 100644 --- a/src/command/client/search/cursor.rs +++ b/src/command/client/search/cursor.rs @@ -57,13 +57,17 @@ impl Cursor { self.index += c.len_utf8(); } - pub fn remove(&mut self) -> char { - self.source.remove(self.index) + pub fn remove(&mut self) -> Option { + if self.index < self.source.len() { + Some(self.source.remove(self.index)) + } else { + None + } } pub fn back(&mut self) -> Option { if self.left() { - Some(self.remove()) + self.remove() } else { None } -- cgit v1.3.1