project_panel: Open files in a permanent tab on middle click (#60563)

# 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

<details>
  <summary>Click to view showcase</summary>


https://github.com/user-attachments/assets/2de5f23d-637f-4ffc-8d03-02dc11714af4

</details>

---

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
This commit is contained in:
Vlad Roskov 2026-07-08 16:06:10 +03:00 committed by GitHub
parent f5c975162c
commit a3a4719a8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -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)

View file

@ -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