add more tests to editor::SelectAllMatches (#25060)

Release Notes:

- N/A
This commit is contained in:
João Marcos 2025-02-18 02:07:57 -03:00 committed by GitHub
parent 06726a28d3
commit 8942e657aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5301,24 +5301,39 @@ async fn test_select_all_matches(cx: &mut gpui::TestAppContext) {
// Test caret-only selections
cx.set_state("abc\nˇabc abc\ndefabc\nabc");
cx.update_editor(|e, window, cx| e.select_all_matches(&SelectAllMatches, window, cx))
.unwrap();
cx.assert_editor_state("«abcˇ»\n«abcˇ» «abcˇ»\ndefabc\n«abcˇ»");
// Test left-to-right selections
cx.set_state("abc\n«abcˇ»\nabc");
cx.update_editor(|e, window, cx| e.select_all_matches(&SelectAllMatches, window, cx))
.unwrap();
cx.assert_editor_state("«abcˇ»\n«abcˇ»\n«abcˇ»");
// Test right-to-left selections
cx.set_state("abc\n«ˇabc»\nabc");
cx.update_editor(|e, window, cx| e.select_all_matches(&SelectAllMatches, window, cx))
.unwrap();
cx.assert_editor_state("«ˇabc»\n«ˇabc»\n«ˇabc»");
// Test selecting whitespace with caret selection
cx.set_state("abc\nˇ abc\nabc");
cx.update_editor(|e, window, cx| e.select_all_matches(&SelectAllMatches, window, cx))
.unwrap();
cx.assert_editor_state("abc\n« ˇ»abc\nabc");
// Test selecting whitespace with left-to-right selection
cx.set_state("abc\n«ˇ »abc\nabc");
cx.update_editor(|e, window, cx| e.select_all_matches(&SelectAllMatches, window, cx))
.unwrap();
cx.assert_editor_state("abc\n«ˇ »abc\nabc");
// Test no matches with right-to-left selection
cx.set_state("abc\n« ˇ»abc\nabc");
cx.update_editor(|e, window, cx| e.select_all_matches(&SelectAllMatches, window, cx))
.unwrap();
cx.assert_editor_state("abc\n« ˇ»abc\nabc");
}
#[gpui::test]