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:
parent
014f93008a
commit
96409965e4
4 changed files with 71 additions and 127 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue