From 8942e657aa792203d0a576982159a4e46d6bed49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos?= Date: Tue, 18 Feb 2025 02:07:57 -0300 Subject: [PATCH] add more tests to `editor::SelectAllMatches` (#25060) Release Notes: - N/A --- crates/editor/src/editor_tests.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index c3778e6f72..c6005bd92b 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -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]