Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix right clicks changing vim mode (#14626)
Congyu16a4c59be0fc
diff --git a/crates/editor/src/mouse_context_menu.rs b/crates/editor/src/mouse_context_menu.rsindex 82e8878b313..1ad8040624a 100644--- a/crates/editor/src/mouse_context_menu.rs+++ b/crates/editor/src/mouse_context_menu.rs@@ -74,10 +74,10 @@ pub fn deploy_context_menu(let context_menu = if let Some(custom) = editor.custom_context_menu.take() {let menu = custom(editor, point, cx);editor.custom_context_menu = Some(custom);- if menu.is_none() {+ let Some(menu) = menu else {return;- }- menu.unwrap()+ };+ menu} else {// Don't show the context menu if there isn't a project associated with this editorif editor.project.is_none() {@@ -85,11 +85,13 @@ pub fn deploy_context_menu(}let display_map = editor.selections.display_map(cx);+ let buffer = &editor.snapshot(cx).buffer_snapshot;+ let anchor = buffer.anchor_before(point.to_point(&display_map));if !display_ranges(&display_map, &editor.selections).any(|r| r.contains(&point)) {// Move the cursor to the clicked location so that dispatched actions make senseeditor.change_selections(None, cx, |s| {s.clear_disjoint();- s.set_pending_display_range(point..point, SelectMode::Character);+ s.set_pending_anchor_range(anchor..anchor, SelectMode::Character);});}diff --git a/crates/editor/src/selections_collection.rs b/crates/editor/src/selections_collection.rsindex 7a448f0b6cc..3c2c4283774 100644--- a/crates/editor/src/selections_collection.rs+++ b/crates/editor/src/selections_collection.rs@@ -426,46 +426,6 @@ impl<'a> MutableSelectionsCollection<'a> {self.selections_changed = true;}- pub(crate) fn set_pending_display_range(- &mut self,- range: Range<DisplayPoint>,- mode: SelectMode,- ) {- let (start, end, reversed) = {- let display_map = self.display_map();- let buffer = self.buffer();- let mut start = range.start;- let mut end = range.end;- let reversed = if start > end {- mem::swap(&mut start, &mut end);- true- } else {- false- };-- let end_bias = if end > start { Bias::Left } else { Bias::Right };- (- buffer.anchor_before(start.to_point(&display_map)),- buffer.anchor_at(end.to_point(&display_map), end_bias),- reversed,- )- };-- let new_pending = PendingSelection {- selection: Selection {- id: post_inc(&mut self.collection.next_selection_id),- start,- end,- reversed,- goal: SelectionGoal::None,- },- mode,- };-- self.collection.pending = Some(new_pending);- self.selections_changed = true;- }-pub(crate) fn set_pending(&mut self, selection: Selection<Anchor>, mode: SelectMode) {self.collection.pending = Some(PendingSelection { selection, mode });self.selections_changed = true;