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
b6ee367ee0/crates/editor/src/element.rs (L591)

being forwarded to `editor.select()` a few lines below
b6ee367ee0/crates/editor/src/element.rs (L667-L675)

resulting in `add == true` and `click_count == 3`, triggering this
b6ee367ee0/crates/editor/src/editor.rs (L2750-L2752)

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

This was added [in
2021](bfecdb7bc0)
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 08:45:43 +02:00 committed by GitHub
parent a07ba3c718
commit 52ea501f4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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);