@@ -85,6 +85,27 @@ impl Prompt {
8585 self.exit_selection();
8686 }
8787
88+ pub fn delete_word_backwards(&mut self) {
89+ use helix_core::get_general_category;
90+ let mut chars = self.line.char_indices().rev();
91+ // TODO add skipping whitespace logic here
92+ let (mut i, cat) = match chars.next() {
93+ Some((i, c)) => (i, get_general_category(c)),
94+ None => return,
95+ };
96+ self.cursor -= 1;
97+ for (nn, nc) in chars {
98+ if get_general_category(nc) != cat {
99+ break;
100+ }
101+ i = nn;
102+ self.cursor -= 1;
103+ }
104+ self.line.drain(i..);
105+ self.completion = (self.completion_fn)(&self.line);
106+ self.exit_selection();
107+ }
108+
88109 pub fn change_completion_selection(&mut self, direction: CompletionDirection) {
89110 if self.completion.is_empty() {
90111 return;
@@ -270,6 +291,10 @@ impl Component for Prompt {
270291 code: KeyCode::Char('a'),
271292 modifiers: KeyModifiers::CONTROL,
272293 } => self.move_start(),
294+ KeyEvent {
295+ code: KeyCode::Char('w'),
296+ modifiers: KeyModifiers::CONTROL,
297+ } => self.delete_word_backwards(),
273298 KeyEvent {
274299 code: KeyCode::Backspace,
275300 modifiers: KeyModifiers::NONE,