Cleanup handling of surrounding word logic, fixing crash in editor::SelectAllMatches (#33353)

This reduces code complexity and avoids unnecessary roundtripping
through `DisplayPoint`. Hopefully this doesn't cause behavior changes,
but has one known behavior improvement:

`clip_at_line_ends` logic caused `is_inside_word` to return false when
on a word at the end of the line. In vim mode, this caused
`select_all_matches` to not select words at the end of lines, and in
some cases crashes due to not finding any selections.

Closes #29823

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-24 23:18:35 -06:00 committed by GitHub
parent 014f93008a
commit 96409965e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 71 additions and 127 deletions

View file

@ -6667,6 +6667,15 @@ async fn test_select_all_matches(cx: &mut TestAppContext) {
cx.update_editor(|e, window, cx| e.select_all_matches(&SelectAllMatches, window, cx))
.unwrap();
cx.assert_editor_state("abc\n« ˇ»abc\nabc");
// Test with a single word and clip_at_line_ends=true (#29823)
cx.set_state("aˇbc");
cx.update_editor(|e, window, cx| {
e.set_clip_at_line_ends(true, cx);
e.select_all_matches(&SelectAllMatches, window, cx).unwrap();
e.set_clip_at_line_ends(false, cx);
});
cx.assert_editor_state("«abcˇ»");
}
#[gpui::test]