diff options
| author | Patrick Decat <pdecat@gmail.com> | 2022-12-03 11:51:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-03 10:51:15 +0000 |
| commit | 1d9ce94f968440e2ca7867406e803c2a18662da4 (patch) | |
| tree | 69443f55bd7ca6513692f8f8115f81aea738fb46 /src/command/client/search/cursor.rs | |
| parent | Handle multiline commands in fish shell (#623) (diff) | |
| download | atuin-1d9ce94f968440e2ca7867406e803c2a18662da4.zip | |
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
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 } |
