Fix multicursors not being added when clicking on line numbers (#28263)

Closes https://github.com/zed-industries/zed/issues/21372

Release Notes:

- Fixed multicursors not being added when clicking on line numbers

-----

I tracked this down to
https://github.com/zed-industries/zed/blob/b6ee367ee0e62a111164dd6e09c534e7e48bad5a/crates/editor/src/element.rs#L591

being forwarded to `editor.select()` a few lines below
https://github.com/zed-industries/zed/blob/b6ee367ee0e62a111164dd6e09c534e7e48bad5a/crates/editor/src/element.rs#L667-L675

resulting in `add == true` and `click_count == 3`, triggering this
https://github.com/zed-industries/zed/blob/b6ee367ee0e62a111164dd6e09c534e7e48bad5a/crates/editor/src/editor.rs#L2750-L2752

... and we end up removing the previous selection. 

This was added [in
2021](https://github.com/zed-industries/zed/commit/bfecdb7bc0e51ed1e37c8d0f61ceb27c5c6b5de9)
under this reasoning:

> This prevents selections added in earlier clicks from being rendered
under the pending selection.

which no longer seems to be an issue, so removing should be safe?

---------

Co-authored-by: Peter Tripp <peter@zed.dev>
This commit is contained in:
neunato
2025-05-06 09:45:43 +03:00
committed by GitHub
co-authored by Peter Tripp
parent a07ba3c718
commit 52ea501f4f
-3
View File
@@ -2972,7 +2972,6 @@ impl Editor {
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let buffer = &display_map.buffer_snapshot;
let newest_selection = self.selections.newest_anchor().clone();
let position = display_map.clip_point(position, Bias::Left);
let start;
@@ -3047,8 +3046,6 @@ impl Editor {
} else {
if !add {
s.clear_disjoint();
} else if click_count > 1 {
s.delete(newest_selection.id)
}
s.set_pending_anchor_range(start..end, mode);