diff options
Diffstat (limited to 'src/command/client/search/cursor.rs')
| -rw-r--r-- | src/command/client/search/cursor.rs | 10 |
1 files changed, 7 insertions, 3 deletions
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<char> { + if self.index < self.source.len() { + Some(self.source.remove(self.index)) + } else { + None + } } pub fn back(&mut self) -> Option<char> { if self.left() { - Some(self.remove()) + self.remove() } else { None } |
