diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b34991e4f5675dee029fd61d12055259b2db770d..03c40d29fca03dcda3697d284571ad69333618e8 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1224,6 +1224,7 @@ 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 { @@ -1233,8 +1234,6 @@ impl Editor { self.update_selections::(selections, None, cx) } - self.pending_selection = Some(PendingSelection { selection, mode }); - cx.notify(); } @@ -4359,19 +4358,16 @@ impl Editor { .display_map .update(cx, |display_map, cx| display_map.snapshot(cx)); let buffer = &display_map.buffer_snapshot; - self.pending_selection = None; + if !self.selections.is_empty() { + 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 - .selections - .iter() - .max_by_key(|s| s.id) - .map(|s| s.head()) - .unwrap(); + let new_cursor_position = self.newest_anchor_selection().head(); self.push_to_nav_history( old_cursor_position.clone(),