From a3a4719a8a246e2f4b88a1fdb0d94809726cad5f Mon Sep 17 00:00:00 2001 From: Vlad Roskov Date: Wed, 8 Jul 2026 16:06:10 +0300 Subject: [PATCH] project_panel: Open files in a permanent tab on middle click (#60563) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective Provide a means of quickly opening a permanent tab from project panel instead of a preview tab. Implements #51866 (_Middle click to open file in a new tab_ with 18×↑) which is also part of #31822 (_Middle Click Improvments_) titled "middle clicking on a file in the project panel should open the file in a non-transient state". With `preview_tabs.enable_preview_from_project_panel` enabled, a click in the project panel opens a preview tab, and there's no easy gesture to open a permanent one instead, simplest one currently being a double click. VS Code and VSCode-based editors recognize middle mouse click as a way to open a permanent tab since 2016 (microsoft/vscode#14453). ## Solution Wired up an `on_aux_click` handler for project panel entries: middle-clicking a file opens it in a permanent tab and focuses it, regardless of the preview tabs setting. Added a line to `docs/src/project-panel.md` to reflect the behavior. ## Testing - Manually tested on Windows: middle click opens a permanent tab, promotes an existing preview tab to a permanent one if already open, does nothing for directories - Haven't tested on macOS/Linux ## Self-Review Checklist: - [ ] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase
Click to view showcase https://github.com/user-attachments/assets/2de5f23d-637f-4ffc-8d03-02dc11714af4
--- Release Notes: - Added support for middle-clicking a file in the project panel to open it in a permanent tab instead of a preview tab --- crates/project_panel/src/project_panel.rs | 10 ++++++++++ docs/src/project-panel.md | 2 ++ 2 files changed, 12 insertions(+) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 8b830513b2c..8b23423a973 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -6015,6 +6015,16 @@ impl ProjectPanel { } }), ) + .on_aux_click( + cx.listener(move |project_panel, event: &gpui::ClickEvent, _, cx| { + if !event.is_middle_click() || show_editor || !kind.is_file() { + return; + } + + project_panel.open_entry(entry_id, true, false, cx); + cx.stop_propagation(); + }), + ) .child( ListItem::new(id) .indent_level(depth) diff --git a/docs/src/project-panel.md b/docs/src/project-panel.md index afee88bbf36..030177af8f6 100644 --- a/docs/src/project-panel.md +++ b/docs/src/project-panel.md @@ -21,6 +21,8 @@ project_panel::CollapseAllEntries} collapses every directory at once. {#kb project_panel::ExpandAllEntries} expands every directory at once. Press {#kb project_panel::Open} or click to preview a selected file, without giving it a permanent tab. Editing the file or double-clicking it promotes it to a permanent tab. +Middle-clicking a file skips the preview and opens it in a permanent, focused tab +right away. ### Auto-reveal