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.
This commit is contained in:
Nathan Sobo 2021-11-23 16:30:33 -07:00
parent 73afb29b04
commit bfecdb7bc0

View file

@ -751,6 +751,16 @@ impl Editor {
if !add {
self.update_selections::<usize>(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::<usize>(cx);
self.update_selections::<usize>(
self.selections(cx)
.filter(|selection| selection.id != newest_selection.id)
.collect(),
false,
cx,
)
}
self.pending_selection = Some(PendingSelection { selection, mode });