From bfecdb7bc0e51ed1e37c8d0f61ceb27c5c6b5de9 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 23 Nov 2021 16:30:33 -0700 Subject: [PATCH] Remove newest selection when adding a selection with a click count > 1 This prevents selections added in earlier clicks from being rendered under the pending selection. --- crates/editor/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/editor/src/lib.rs b/crates/editor/src/lib.rs index 020d7593cf..4443d23ad7 100644 --- a/crates/editor/src/lib.rs +++ b/crates/editor/src/lib.rs @@ -751,6 +751,16 @@ impl Editor { if !add { self.update_selections::(Vec::new(), false, cx); + } else if click_count > 1 { + // Remove the newest selection since it was only added as part of this multi-click. + let newest_selection = self.newest_selection::(cx); + self.update_selections::( + self.selections(cx) + .filter(|selection| selection.id != newest_selection.id) + .collect(), + false, + cx, + ) } self.pending_selection = Some(PendingSelection { selection, mode });