diff options
author | Ivan Tham | 2021-06-12 17:00:50 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-14 16:06:53 +0000 |
commit | 1bda4541491bf0fc8129214bb52515a32b8d4978 (patch) | |
tree | 633ec63cade566a1b51c39764cc5b0b9252aac85 /helix-term/src | |
parent | e819121f6e3a462b57e728fe5156783e1a8a3035 (diff) |
Add ctrl-w for prompt
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/ui/prompt.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index c00968d0..433de15e 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -85,6 +85,27 @@ impl Prompt { self.exit_selection(); } + pub fn delete_word_backwards(&mut self) { + use helix_core::get_general_category; + let mut chars = self.line.char_indices().rev(); + // TODO add skipping whitespace logic here + let (mut i, cat) = match chars.next() { + Some((i, c)) => (i, get_general_category(c)), + None => return, + }; + self.cursor -= 1; + for (nn, nc) in chars { + if get_general_category(nc) != cat { + break; + } + i = nn; + self.cursor -= 1; + } + self.line.drain(i..); + self.completion = (self.completion_fn)(&self.line); + self.exit_selection(); + } + pub fn change_completion_selection(&mut self, direction: CompletionDirection) { if self.completion.is_empty() { return; @@ -271,6 +292,10 @@ impl Component for Prompt { modifiers: KeyModifiers::CONTROL, } => self.move_start(), KeyEvent { + code: KeyCode::Char('w'), + modifiers: KeyModifiers::CONTROL, + } => self.delete_word_backwards(), + KeyEvent { code: KeyCode::Backspace, modifiers: KeyModifiers::NONE, } => { |