Multi-cursor removal possibility (#13431)

Release Notes:

- Added the ability to remove multi-cursors by clicking on them again.
([#13058](https://github.com/zed-industries/zed/issues/13058)).
This commit is contained in:
Krzysztof Witkowski 2024-06-24 10:32:37 +02:00 committed by GitHub
parent 354427413a
commit 10f7ca65cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 91 additions and 7 deletions

View file

@ -436,6 +436,57 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) {
);
}
#[gpui::test]
fn test_multiple_cursor_removal(cx: &mut TestAppContext) {
init_test(cx, |_| {});
let editor = cx.add_window(|cx| {
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\nddddddd\n", cx);
build_editor(buffer, cx)
});
_ = editor.update(cx, |view, cx| {
view.begin_selection(DisplayPoint::new(DisplayRow(2), 1), false, 1, cx);
});
_ = editor.update(cx, |view, cx| {
view.end_selection(cx);
});
_ = editor.update(cx, |view, cx| {
view.begin_selection(DisplayPoint::new(DisplayRow(3), 2), true, 1, cx);
});
_ = editor.update(cx, |view, cx| {
view.end_selection(cx);
});
assert_eq!(
editor
.update(cx, |view, cx| view.selections.display_ranges(cx))
.unwrap(),
[
DisplayPoint::new(DisplayRow(2), 1)..DisplayPoint::new(DisplayRow(2), 1),
DisplayPoint::new(DisplayRow(3), 2)..DisplayPoint::new(DisplayRow(3), 2)
]
);
_ = editor.update(cx, |view, cx| {
view.begin_selection(DisplayPoint::new(DisplayRow(2), 1), true, 1, cx);
});
_ = editor.update(cx, |view, cx| {
view.end_selection(cx);
});
assert_eq!(
editor
.update(cx, |view, cx| view.selections.display_ranges(cx))
.unwrap(),
[DisplayPoint::new(DisplayRow(3), 2)..DisplayPoint::new(DisplayRow(3), 2)]
);
}
#[gpui::test]
fn test_canceling_pending_selection(cx: &mut TestAppContext) {
init_test(cx, |_| {});