fix: highlight all search matches before word navigation
This commit is contained in:
+40
-1
@@ -120,12 +120,35 @@ fn wait_until(session: &mut EditorSession, ready: impl Fn(&EditorSession) -> boo
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn star_search_arms_without_moving_then_navigates_and_rearms_for_a_new_word_or_mode() {
|
||||
let fixture = Fixture::new();
|
||||
let mut editor = fixture.editor("cat dog cat dog");
|
||||
keys(&mut editor, "l2*");
|
||||
assert_eq!(editor.cursor(), Cursor { row: 0, column: 1 });
|
||||
assert_eq!(editor.search_match().unwrap().start, Cursor::default());
|
||||
keys(&mut editor, "*");
|
||||
assert_eq!(editor.cursor(), Cursor { row: 0, column: 8 });
|
||||
keys(&mut editor, "w*");
|
||||
assert_eq!(editor.cursor(), Cursor { row: 0, column: 12 });
|
||||
keys(&mut editor, "*");
|
||||
assert_eq!(editor.cursor(), Cursor { row: 0, column: 4 });
|
||||
|
||||
keys(&mut editor, "/cat");
|
||||
editor.handle(Input::Enter);
|
||||
assert_eq!(editor.cursor(), Cursor { row: 0, column: 8 });
|
||||
keys(&mut editor, "*");
|
||||
assert_eq!(editor.cursor(), Cursor { row: 0, column: 8 });
|
||||
keys(&mut editor, "*");
|
||||
assert_eq!(editor.cursor(), Cursor::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn star_search_keeps_whole_word_counts_history_and_literal_search_distinct() {
|
||||
let fixture = Fixture::new();
|
||||
let text = "cat\nscatter\ncat_cat\ncat2\n2cat\nCat\ncat\ncat\n\n";
|
||||
let mut editor = fixture.editor(text);
|
||||
keys(&mut editor, "l*");
|
||||
keys(&mut editor, "l**");
|
||||
assert_eq!(editor.cursor(), Cursor { row: 6, column: 0 });
|
||||
assert_eq!(editor.search_match().unwrap().end_column, 3);
|
||||
keys(&mut editor, "nN2*");
|
||||
@@ -169,6 +192,9 @@ fn star_search_uses_unicode_words_and_vim_same_line_fallbacks() {
|
||||
] {
|
||||
let mut editor = fixture.editor(text);
|
||||
keys(&mut editor, positioning);
|
||||
let origin = editor.cursor();
|
||||
editor.handle(Input::Char('*'));
|
||||
assert_eq!(editor.cursor(), origin, "{text:?}");
|
||||
editor.handle(Input::Char('*'));
|
||||
assert_eq!(editor.cursor(), Cursor { row, column: 0 }, "{text:?}");
|
||||
assert_eq!(
|
||||
@@ -191,6 +217,11 @@ fn star_search_rebinding_moves_all_carets_and_remains_view_local() {
|
||||
);
|
||||
session.handle(Input::Ctrl('e'));
|
||||
session_keys(&mut session, "2q");
|
||||
assert_eq!(
|
||||
session.editor().carets(),
|
||||
[Cursor::default(), Cursor { row: 1, column: 0 }]
|
||||
);
|
||||
session_keys(&mut session, "2q");
|
||||
assert_eq!(
|
||||
session.editor().carets(),
|
||||
[Cursor { row: 0, column: 16 }, Cursor { row: 1, column: 16 }]
|
||||
@@ -439,6 +470,14 @@ fn readonly_before_and_historical_after_seeks_preserve_snapshots_and_folded_exce
|
||||
}
|
||||
);
|
||||
session_keys(&mut session, "*");
|
||||
assert_eq!(
|
||||
session.editor().cursor(),
|
||||
Cursor {
|
||||
row: 19,
|
||||
column: second_x
|
||||
}
|
||||
);
|
||||
session_keys(&mut session, "*");
|
||||
assert_eq!(
|
||||
session.editor().cursor(),
|
||||
Cursor {
|
||||
|
||||
Reference in New Issue
Block a user