editor: Fix setting multi_cursor_modifier opens implementation in new pane instead of new tab (#41963)
Closes #41014 Release Notes: - Fixed an issue where `multi_cursor_modifier` set to `cmd_or_ctrl` opens implementation in new pane instead of new tab.
This commit is contained in:
+13
-14
@@ -7599,18 +7599,17 @@ impl Editor {
|
||||
)
|
||||
}
|
||||
|
||||
fn multi_cursor_modifier(invert: bool, modifiers: &Modifiers, cx: &mut Context<Self>) -> bool {
|
||||
let multi_cursor_setting = EditorSettings::get_global(cx).multi_cursor_modifier;
|
||||
if invert {
|
||||
match multi_cursor_setting {
|
||||
MultiCursorModifier::Alt => modifiers.alt,
|
||||
MultiCursorModifier::CmdOrCtrl => modifiers.secondary(),
|
||||
}
|
||||
} else {
|
||||
match multi_cursor_setting {
|
||||
MultiCursorModifier::Alt => modifiers.secondary(),
|
||||
MultiCursorModifier::CmdOrCtrl => modifiers.alt,
|
||||
}
|
||||
fn is_cmd_or_ctrl_pressed(modifiers: &Modifiers, cx: &mut Context<Self>) -> bool {
|
||||
match EditorSettings::get_global(cx).multi_cursor_modifier {
|
||||
MultiCursorModifier::Alt => modifiers.secondary(),
|
||||
MultiCursorModifier::CmdOrCtrl => modifiers.alt,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_alt_pressed(modifiers: &Modifiers, cx: &mut Context<Self>) -> bool {
|
||||
match EditorSettings::get_global(cx).multi_cursor_modifier {
|
||||
MultiCursorModifier::Alt => modifiers.alt,
|
||||
MultiCursorModifier::CmdOrCtrl => modifiers.secondary(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7619,9 +7618,9 @@ impl Editor {
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<ColumnarMode> {
|
||||
if modifiers.shift && modifiers.number_of_modifiers() == 2 {
|
||||
if Self::multi_cursor_modifier(false, modifiers, cx) {
|
||||
if Self::is_cmd_or_ctrl_pressed(modifiers, cx) {
|
||||
Some(ColumnarMode::FromMouse)
|
||||
} else if Self::multi_cursor_modifier(true, modifiers, cx) {
|
||||
} else if Self::is_alt_pressed(modifiers, cx) {
|
||||
Some(ColumnarMode::FromSelection)
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -820,7 +820,7 @@ impl EditorElement {
|
||||
editor.select(
|
||||
SelectPhase::Begin {
|
||||
position,
|
||||
add: Editor::multi_cursor_modifier(true, &modifiers, cx),
|
||||
add: Editor::is_alt_pressed(&modifiers, cx),
|
||||
click_count,
|
||||
},
|
||||
window,
|
||||
@@ -1004,7 +1004,7 @@ impl EditorElement {
|
||||
let text_hitbox = &position_map.text_hitbox;
|
||||
let pending_nonempty_selections = editor.has_pending_nonempty_selection();
|
||||
|
||||
let hovered_link_modifier = Editor::multi_cursor_modifier(false, &event.modifiers(), cx);
|
||||
let hovered_link_modifier = Editor::is_cmd_or_ctrl_pressed(&event.modifiers(), cx);
|
||||
|
||||
if let Some(mouse_position) = event.mouse_position()
|
||||
&& !pending_nonempty_selections
|
||||
|
||||
@@ -116,7 +116,7 @@ impl Editor {
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let hovered_link_modifier = Editor::multi_cursor_modifier(false, &modifiers, cx);
|
||||
let hovered_link_modifier = Editor::is_cmd_or_ctrl_pressed(&modifiers, cx);
|
||||
if !hovered_link_modifier || self.has_pending_selection() {
|
||||
self.hide_hovered_link(cx);
|
||||
return;
|
||||
@@ -241,8 +241,8 @@ impl Editor {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let navigate_task =
|
||||
self.navigate_to_hover_links(None, links, modifiers.alt, window, cx);
|
||||
let split = Self::is_alt_pressed(&modifiers, cx);
|
||||
let navigate_task = self.navigate_to_hover_links(None, links, split, window, cx);
|
||||
self.select(SelectPhase::End, window, cx);
|
||||
return navigate_task;
|
||||
}
|
||||
@@ -261,7 +261,8 @@ impl Editor {
|
||||
);
|
||||
|
||||
let navigate_task = if point.as_valid().is_some() {
|
||||
match (modifiers.shift, modifiers.alt) {
|
||||
let split = Self::is_alt_pressed(&modifiers, cx);
|
||||
match (modifiers.shift, split) {
|
||||
(true, true) => {
|
||||
self.go_to_type_definition_split(&GoToTypeDefinitionSplit, window, cx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user