fix: clear search highlighting on Normal escape
This commit is contained in:
@@ -120,6 +120,36 @@ fn wait_until(session: &mut EditorSession, ready: impl Fn(&EditorSession) -> boo
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normal_escape_hides_highlights_but_retains_search_and_rearms_star() {
|
||||
let fixture = Fixture::new();
|
||||
let mut editor = fixture.editor("cat cat");
|
||||
keys(&mut editor, "*");
|
||||
assert_eq!(editor.search_matches_on_row(0).count(), 2);
|
||||
editor.handle(Input::Escape);
|
||||
assert_eq!(editor.search_matches_on_row(0).count(), 0);
|
||||
assert_eq!(editor.search_match(), None);
|
||||
assert_eq!(editor.cursor(), Cursor::default());
|
||||
keys(&mut editor, "*");
|
||||
assert_eq!(editor.cursor(), Cursor::default());
|
||||
assert_eq!(editor.search_matches_on_row(0).count(), 2);
|
||||
keys(&mut editor, "*");
|
||||
assert_eq!(editor.cursor(), Cursor { row: 0, column: 4 });
|
||||
editor.handle(Input::Escape);
|
||||
keys(&mut editor, "n");
|
||||
assert_eq!(editor.cursor(), Cursor::default());
|
||||
assert_eq!(editor.search_matches_on_row(0).count(), 2);
|
||||
keys(&mut editor, "/missing");
|
||||
editor.handle(Input::Escape);
|
||||
assert_eq!(editor.search_matches_on_row(0).count(), 2);
|
||||
editor.handle(Input::Escape);
|
||||
editor.handle(Input::Char('/'));
|
||||
editor.handle(Input::Enter);
|
||||
assert_eq!(editor.cursor(), Cursor { row: 0, column: 4 });
|
||||
assert_eq!(editor.search_matches_on_row(0).count(), 2);
|
||||
assert!(!editor.dirty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn star_search_arms_without_moving_then_navigates_and_rearms_for_a_new_word_or_mode() {
|
||||
let fixture = Fixture::new();
|
||||
|
||||
Reference in New Issue
Block a user