Add regression test for #11671 (#32250)

I can reproduce #11671 on current Nightly but not on `main`; it looks
like https://github.com/zed-industries/zed/pull/32204 fixed it. So I'm
adding a regression test and closing that issue.

Closes #11671

Release Notes:

- N/A
This commit is contained in:
Richard Feldman 2025-06-06 10:29:59 -04:00 committed by GitHub
parent 6ea4d2b30d
commit 2e883be4b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22003,3 +22003,53 @@ async fn test_pulling_diagnostics(cx: &mut TestAppContext) {
);
ensure_result_id(Some(final_requests.to_string()), cx);
}
#[gpui::test]
async fn test_add_selection_after_moving_with_multiple_cursors(cx: &mut TestAppContext) {
// Regression test for issue #11671
// Previously, adding a cursor after moving multiple cursors would reset
// the cursor count instead of adding to the existing cursors.
init_test(cx, |_| {});
let mut cx = EditorTestContext::new(cx).await;
// Create a simple buffer with cursor at start
cx.set_state(indoc! {"
ˇaaaa
bbbb
cccc
dddd
eeee
ffff
gggg
hhhh"});
// Add 2 cursors below (so we have 3 total)
cx.update_editor(|editor, window, cx| {
editor.add_selection_below(&Default::default(), window, cx);
editor.add_selection_below(&Default::default(), window, cx);
});
// Verify we have 3 cursors
let initial_count = cx.update_editor(|editor, _, _| editor.selections.count());
assert_eq!(
initial_count, 3,
"Should have 3 cursors after adding 2 below"
);
// Move down one line
cx.update_editor(|editor, window, cx| {
editor.move_down(&MoveDown, window, cx);
});
// Add another cursor below
cx.update_editor(|editor, window, cx| {
editor.add_selection_below(&Default::default(), window, cx);
});
// Should now have 4 cursors (3 original + 1 new)
let final_count = cx.update_editor(|editor, _, _| editor.selections.count());
assert_eq!(
final_count, 4,
"Should have 4 cursors after moving and adding another"
);
}