Unify selection directions when performing editor: select all selections
(#23993)
Closes https://github.com/zed-industries/zed/issues/19569 Current behavior: https://github.com/user-attachments/assets/1de764c9-7c62-49ad-b24b-6e85760857db After PR: https://github.com/user-attachments/assets/651d8e50-95e2-4513-852b-9557d00d2b62 Release Notes: - Unified selection directions when performing `editor: select all selections`. --------- Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
parent
f29b33ec85
commit
4c8b5ea4f7
2 changed files with 22 additions and 0 deletions
|
@ -8827,6 +8827,12 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let reversed = self.selections.oldest::<usize>(cx).reversed;
|
||||||
|
|
||||||
|
for selection in new_selections.iter_mut() {
|
||||||
|
selection.reversed = reversed;
|
||||||
|
}
|
||||||
|
|
||||||
select_next_state.done = true;
|
select_next_state.done = true;
|
||||||
self.unfold_ranges(
|
self.unfold_ranges(
|
||||||
&new_selections
|
&new_selections
|
||||||
|
|
|
@ -5236,11 +5236,27 @@ async fn test_select_all_matches(cx: &mut gpui::TestAppContext) {
|
||||||
init_test(cx, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
let mut cx = EditorTestContext::new(cx).await;
|
let mut cx = EditorTestContext::new(cx).await;
|
||||||
|
|
||||||
|
// Test caret-only selections
|
||||||
cx.set_state("abc\nˇabc abc\ndefabc\nabc");
|
cx.set_state("abc\nˇabc abc\ndefabc\nabc");
|
||||||
|
|
||||||
cx.update_editor(|e, window, cx| e.select_all_matches(&SelectAllMatches, window, cx))
|
cx.update_editor(|e, window, cx| e.select_all_matches(&SelectAllMatches, window, cx))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
cx.assert_editor_state("«abcˇ»\n«abcˇ» «abcˇ»\ndefabc\n«abcˇ»");
|
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»");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue