mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
Fix right clicks changing vim mode (#14626)
Release Notes: - Fixed right clicks changing vim mode (#14625). before: https://github.com/user-attachments/assets/97f4c971-6b59-412d-844a-23e0bc4289aa after: https://github.com/user-attachments/assets/3fc9adf3-2572-428d-8674-b3c8317e457e
This commit is contained in:
parent
90a46b0463
commit
16a4c59be0
@ -74,10 +74,10 @@ pub fn deploy_context_menu(
|
|||||||
let context_menu = if let Some(custom) = editor.custom_context_menu.take() {
|
let context_menu = if let Some(custom) = editor.custom_context_menu.take() {
|
||||||
let menu = custom(editor, point, cx);
|
let menu = custom(editor, point, cx);
|
||||||
editor.custom_context_menu = Some(custom);
|
editor.custom_context_menu = Some(custom);
|
||||||
if menu.is_none() {
|
let Some(menu) = menu else {
|
||||||
return;
|
return;
|
||||||
}
|
};
|
||||||
menu.unwrap()
|
menu
|
||||||
} else {
|
} else {
|
||||||
// Don't show the context menu if there isn't a project associated with this editor
|
// Don't show the context menu if there isn't a project associated with this editor
|
||||||
if editor.project.is_none() {
|
if editor.project.is_none() {
|
||||||
@ -85,11 +85,13 @@ pub fn deploy_context_menu(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let display_map = editor.selections.display_map(cx);
|
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)) {
|
if !display_ranges(&display_map, &editor.selections).any(|r| r.contains(&point)) {
|
||||||
// Move the cursor to the clicked location so that dispatched actions make sense
|
// Move the cursor to the clicked location so that dispatched actions make sense
|
||||||
editor.change_selections(None, cx, |s| {
|
editor.change_selections(None, cx, |s| {
|
||||||
s.clear_disjoint();
|
s.clear_disjoint();
|
||||||
s.set_pending_display_range(point..point, SelectMode::Character);
|
s.set_pending_anchor_range(anchor..anchor, SelectMode::Character);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,46 +426,6 @@ impl<'a> MutableSelectionsCollection<'a> {
|
|||||||
self.selections_changed = true;
|
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) {
|
pub(crate) fn set_pending(&mut self, selection: Selection<Anchor>, mode: SelectMode) {
|
||||||
self.collection.pending = Some(PendingSelection { selection, mode });
|
self.collection.pending = Some(PendingSelection { selection, mode });
|
||||||
self.selections_changed = true;
|
self.selections_changed = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user