fix: move word search activation onto its match

This commit is contained in:
Valdemar Lorenzen
2026-10-15 12:38:50 +02:00
parent f5c6d098f8
commit 3a7e2074b4
3 changed files with 38 additions and 11 deletions
+30 -2
View File
@@ -120,6 +120,36 @@ fn wait_until(session: &mut EditorSession, ready: impl Fn(&EditorSession) -> boo
}
}
#[test]
fn star_activation_moves_onto_the_selected_word_only_when_outside_it() {
let fixture = Fixture::new();
for (text, column, expected) in [
(" word word", 0, 2),
(" word word", 1, 2),
(" word word", 2, 2),
(" word word", 4, 4),
("-- word word", 0, 3),
("\t界e\u{301} 界e\u{301}", 0, 1),
(" .* .*", 0, 1),
] {
let mut editor = fixture.editor(text);
keys(&mut editor, &"l".repeat(column));
keys(&mut editor, "*");
assert_eq!(
editor.cursor(),
Cursor {
row: 0,
column: expected
},
"{text:?}"
);
let first = editor.search_match().unwrap().start;
keys(&mut editor, "*");
assert!(editor.cursor().column > first.column, "{text:?}");
assert!(!editor.dirty());
}
}
#[test]
fn submitting_search_keeps_each_caret_inside_a_current_match() {
let fixture = Fixture::new();
@@ -253,9 +283,7 @@ 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!(