From ad9a0e2d4f1ab09441c41d6fd05739b71a7d5ddd Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 11 Feb 2022 09:21:04 -0700 Subject: [PATCH] Revert "Ensure there's always at least one selection in the editor" This reverts commit b1a44b5816eeb021efbd5bb49cd5a60573cf508a. --- crates/editor/src/editor.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index d433bc3398..7bdc1d7be0 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1242,7 +1242,6 @@ impl Editor { goal: SelectionGoal::None, }; - self.pending_selection = Some(PendingSelection { selection, mode }); if !add { self.update_selections::(Vec::new(), None, cx); } else if click_count > 1 { @@ -1252,6 +1251,8 @@ impl Editor { self.update_selections::(selections, None, cx) } + self.pending_selection = Some(PendingSelection { selection, mode }); + cx.notify(); } @@ -4436,16 +4437,19 @@ impl Editor { .display_map .update(cx, |display_map, cx| display_map.snapshot(cx)); let buffer = &display_map.buffer_snapshot; - if !self.selections.is_empty() { - self.pending_selection = None; - } + self.pending_selection = None; self.add_selections_state = None; self.select_next_state = None; self.select_larger_syntax_node_stack.clear(); self.autoclose_stack.invalidate(&self.selections, &buffer); self.snippet_stack.invalidate(&self.selections, &buffer); - let new_cursor_position = self.newest_anchor_selection().head(); + let new_cursor_position = self + .selections + .iter() + .max_by_key(|s| s.id) + .map(|s| s.head()) + .unwrap(); self.push_to_nav_history( old_cursor_position.clone(),