mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-12-01 03:15:33 +03:00
Add ctrl-w for prompt
This commit is contained in:
parent
e819121f6e
commit
1bda454149
@ -94,6 +94,8 @@ pub use ropey::{Rope, RopeSlice};
|
|||||||
|
|
||||||
pub use tendril::StrTendril as Tendril;
|
pub use tendril::StrTendril as Tendril;
|
||||||
|
|
||||||
|
pub use unicode_general_category::get_general_category;
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use {regex, tree_sitter};
|
pub use {regex, tree_sitter};
|
||||||
|
|
||||||
|
@ -85,6 +85,27 @@ impl Prompt {
|
|||||||
self.exit_selection();
|
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) {
|
pub fn change_completion_selection(&mut self, direction: CompletionDirection) {
|
||||||
if self.completion.is_empty() {
|
if self.completion.is_empty() {
|
||||||
return;
|
return;
|
||||||
@ -270,6 +291,10 @@ impl Component for Prompt {
|
|||||||
code: KeyCode::Char('a'),
|
code: KeyCode::Char('a'),
|
||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
} => self.move_start(),
|
} => self.move_start(),
|
||||||
|
KeyEvent {
|
||||||
|
code: KeyCode::Char('w'),
|
||||||
|
modifiers: KeyModifiers::CONTROL,
|
||||||
|
} => self.delete_word_backwards(),
|
||||||
KeyEvent {
|
KeyEvent {
|
||||||
code: KeyCode::Backspace,
|
code: KeyCode::Backspace,
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
|
Loading…
Reference in New Issue
Block a user