editor: Make cmd-alt-click behavior more consistent (#38733)
Fixes two inconsistencies around the behavior of cmd-alt-click that mess with my VSCode muscle memory: - The definition is opened in a pane to the right of the current pane, unless there exists an adjacent pane to the left and not to the right, in which case it's opened in the pane on the left - In case Go to Definition needs to open a multibuffer, cmd-alt-click does not open it in an existing pane to the right of the current pane, it always creates a new pane directly to the right of the current pane This PR irons out this behavior by always going to the definition in the pane directly to the right of the current one, creating one only if one doesn't yet exist. If changing `Workspace::adjacent_pane` to not consider an existing pane to the left is undesirable then that logic could be moved somewhere else, or we can make it user configurable if necessary. Also happy to split this PR up if either of these changes is controversial 🙂 Before: https://github.com/user-attachments/assets/395754cd-6ecb-40bf-ae61-ee8903eed4ae After: https://github.com/user-attachments/assets/002797b1-51a7-48e5-a8d0-100d3a5049eb Release Notes: - Made the behavior of cmd-alt-click more consistent --------- Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>
This commit is contained in:
co-authored by
Joseph T. Lyons
parent
90ea252c82
commit
42ef3e5d3d
@@ -16918,7 +16918,8 @@ impl Editor {
|
||||
let item_id = item.item_id();
|
||||
|
||||
if split {
|
||||
workspace.split_item(SplitDirection::Right, item, window, cx);
|
||||
let pane = workspace.adjacent_pane(window, cx);
|
||||
workspace.add_item(pane, item, None, true, true, window, cx);
|
||||
} else if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
|
||||
let (preview_item_id, preview_item_idx) =
|
||||
workspace.active_pane().read_with(cx, |pane, _| {
|
||||
|
||||
@@ -4176,7 +4176,6 @@ impl Workspace {
|
||||
|
||||
pub fn adjacent_pane(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Entity<Pane> {
|
||||
self.find_pane_in_direction(SplitDirection::Right, cx)
|
||||
.or_else(|| self.find_pane_in_direction(SplitDirection::Left, cx))
|
||||
.unwrap_or_else(|| {
|
||||
self.split_pane(self.active_pane.clone(), SplitDirection::Right, window, cx)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user