feat(tui): support Ctrl+Backspace in text inputs
This commit is contained in:
1 parent
315567a79c
commit
cccf65981a
13 files changed
+99
-16
No files matched your search
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use crossterm::event::KeyModifiers;
|
||||
|
||||
#[test]
|
||||
fn confirm_keeps_query_but_deactivates() {
|
||||
@@ -50,3 +51,26 @@ fn highlight_spans_marks_each_case_insensitive_match() {
|
||||
assert!(spans[2].style.add_modifier.contains(Modifier::BOLD));
|
||||
assert!(spans[2].style.add_modifier.contains(Modifier::UNDERLINED));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_backspace_deletes_the_previous_word() {
|
||||
let mut search = SearchState {
|
||||
query: "alpha βeta ".to_owned(),
|
||||
..SearchState::default()
|
||||
};
|
||||
|
||||
search.backspace(KeyModifiers::CONTROL);
|
||||
|
||||
assert_eq!(search.query, "alpha ");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deleting_a_word_before_the_cursor_preserves_the_suffix() {
|
||||
let mut text = "hello brave world".to_owned();
|
||||
let cursor = "hello brave".chars().count();
|
||||
|
||||
let cursor = delete_previous_word(&mut text, cursor);
|
||||
|
||||
assert_eq!(text, "hello world");
|
||||
assert_eq!(cursor, "hello ".chars().count());
|
||||
}
|
||||
Reference in new issue
Block a user