outline_panel: Add setting to hide symbols in multi-buffer views (#63404)
Closes https://github.com/zed-industries/zed/issues/60242 # Objective When reviewing a branch diff — or project search results — the outline panel lists every affected excerpt and symbol beneath each file. On a diff touching more than a handful of files, this consumes so much vertical space that you cannot see the list of changed files at all, which is usually the thing you want the panel for. Existing settings don't cover this: - `expand_outlines_with_depth: 0` still renders excerpt rows and top-level symbol rows. - Collapsing a file row in the panel is coupled to folding that buffer in the editor, so it can't be used purely to tidy the panel. ## Solution A display-only mode that reduces multi-buffer views to just the directory/file tree. - New `outline_panel.multi_buffer_hide_symbols` setting (default `false`). When enabled, multi-buffer views render only directory, file and folded-directory rows — excerpt, symbol and search-match rows are hidden. - New `outline panel: toggle symbols` action, plus a button in the panel footer, which toggles an in-memory per-panel override of the setting (the same pattern as `editor: toggle inlay hints`). Changing the setting clears the override, so the setting wins. - Single-file views are exempt, and the footer button is not shown there — the panel contains only symbols in that case, so hiding them would leave it empty. - The filter is display-only: `collapsed_entries` and editor buffer folding are never touched. - Outline fetching is skipped while the mode is active, so large diffs don't pay for outlines that will not be rendered. Turning the mode off re-triggers fetching. This adds one new icon, `file_code_off`, used by the footer button when symbols are hidden. cc @zed-industries/design for review per the icon guidelines — it is `file_code` with the slash and outline gaps from `file_ignored`, keeping the parts of the chevrons that fall on the near side of the slash. ## Testing Three new tests in `crates/outline_panel/src/outline_panel.rs`: - `test_hide_symbols_in_multibuffer` — outline rows are present by default; only `Fs`/`FoldedDirs` entries remain once the mode is enabled via the setting (which also exercises the settings observer) and via the action; outline rows return when it is toggled off, confirming outlines are re-fetched; asserts `collapsed_entries` is unchanged at every step, covering the display-only guarantee. - `test_hide_symbols_exempts_singleton` — a single-file view still renders its outline with the setting enabled. - `test_hide_symbols_hides_search_matches` — project search match rows are hidden while files and directories still render, and return when toggled off. `cargo test -p outline_panel` (15 passing), `cargo test -p icons`, `cargo test -p settings_ui -p settings_content`, and `./script/clippy` on the touched crates are all green. Tested manually on macOS against a branch diff, project search results, and single-file buffers, checking both the setting and the action (from the panel footer button and from the command palette with focus outside the panel), and that expanding/collapsing directories and editor folding still behave as before. ## Self-Review Checklist: - [x] 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) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase <!-- Screenshots go here: branch-diff before/after, footer button icon states, search before/after, single-file exemption --> | | Symbols shown (default) | Symbols hidden | | --- | --- | --- | | **Footer toggle** | <img src="https://github.com/user-attachments/assets/393f128d-1a7c-43a8-97b8-8176a07b45c7" width="260"> | <img src="https://github.com/user-attachments/assets/87c60dd4-d5b7-48f8-9255-226c4a94a586" width="260"> | | **Branch diff** | <img src="https://github.com/user-attachments/assets/79357325-7d7d-40f7-8067-4ae59a824f87" width="420"> | <img src="https://github.com/user-attachments/assets/8a3bbc7e-90d4-4638-9f1d-1ba3091eccfd" width="420"> | | **Project search** | <img src="https://github.com/user-attachments/assets/76e3cf18-d624-42f8-8801-f496bf54a552" width="420"> | <img src="https://github.com/user-attachments/assets/2a34e899-b9f4-465e-b571-75d3d54d00eb" width="420"> | Single-file views are unaffected — symbols still render, and the toggle is not offered: <img src="https://github.com/user-attachments/assets/76c47884-96db-4071-bcc1-931c4283e36f" width="640"> --- Release Notes: - Fixed too many outlines shown per excerpt in the outline panel. Added an `outline_panel.multi_buffer_hide_symbols` setting and an `outline panel: toggle symbols` action to show only files and directories in the outline panel for multi-buffer views. --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
1 parent
fd35a813e9
commit
bb501d9221
9 files changed
+1413
-91
No files matched your search
@@ -0,0 +1,6 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1.91129 3.37805L14.0887 12.6219" stroke="#DCE0E5" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M3.94603 7.6676V12.3242C3.94603 12.6109 4.05281 12.8859 4.24288 13.0886C4.43294 13.2914 4.69073 13.4053 4.95952 13.4053H10.7097" stroke="#DCE0E5" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.95952 2.59473H8.54451C9.16704 2.59473 9.76181 2.8524 10.1876 3.30656L11.4448 4.64763C11.8362 5.06507 12.054 5.61581 12.054 6.18801V7.98098" stroke="#DCE0E5" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M6.2881 7.1399L5.6 8L6.8 9.5" stroke="#DCE0E5" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 815 B |
@@ -1008,6 +1008,11 @@
|
||||
// Default depth to expand outline items in the current file.
|
||||
// Set to 0 to collapse all items that have children, 1 or higher to collapse items at that depth or deeper.
|
||||
"expand_outlines_with_depth": 100,
|
||||
// Whether to hide symbols, excerpts and search matches in the outline panel
|
||||
// when a multi-buffer view (e.g. a diff or search results) is active,
|
||||
// showing only files and directories.
|
||||
// Does not affect single-file views.
|
||||
"multi_buffer_hide_symbols": false,
|
||||
},
|
||||
"collaboration_panel": {
|
||||
// Whether to show the collaboration panel button in the status bar.
|
||||
|
||||
@@ -127,6 +127,7 @@ pub enum IconName {
|
||||
FastForwardOff,
|
||||
File,
|
||||
FileCode,
|
||||
FileCodeOff,
|
||||
FileDiff,
|
||||
FileDoc,
|
||||
FileGeneric,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -18,6 +18,7 @@ pub struct OutlinePanelSettings {
|
||||
pub auto_fold_dirs: bool,
|
||||
pub scrollbar: ScrollbarSettings,
|
||||
pub expand_outlines_with_depth: usize,
|
||||
pub multi_buffer_hide_symbols: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
@@ -76,6 +77,7 @@ impl Settings for OutlinePanelSettings {
|
||||
.map(ui_scrollbar_settings_from_raw),
|
||||
},
|
||||
expand_outlines_with_depth: panel.expand_outlines_with_depth.unwrap(),
|
||||
multi_buffer_hide_symbols: panel.multi_buffer_hide_symbols.unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1210,6 +1210,13 @@ pub struct OutlinePanelSettingsContent {
|
||||
///
|
||||
/// Default: 100
|
||||
pub expand_outlines_with_depth: Option<usize>,
|
||||
/// Whether to hide symbols, excerpts and search matches in the outline panel
|
||||
/// when a multi-buffer view (e.g. a diff or search results) is active,
|
||||
/// showing only files and directories.
|
||||
/// Does not affect single-file views.
|
||||
///
|
||||
/// Default: false
|
||||
pub multi_buffer_hide_symbols: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
|
||||
@@ -5892,7 +5892,7 @@ fn panels_page() -> SettingsPage {
|
||||
]
|
||||
}
|
||||
|
||||
fn outline_panel_section() -> [SettingsPageItem; 11] {
|
||||
fn outline_panel_section() -> [SettingsPageItem; 12] {
|
||||
[
|
||||
SettingsPageItem::SectionHeader("Outline Panel"),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
@@ -6108,6 +6108,29 @@ fn panels_page() -> SettingsPage {
|
||||
}),
|
||||
metadata: None,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Hide Symbols in Multi-Buffers",
|
||||
description: "Whether to hide symbols, excerpts and search matches in the outline panel when a multi-buffer view is active.",
|
||||
field: Box::new(SettingField {
|
||||
organization_override: None,
|
||||
json_path: Some("outline_panel.multi_buffer_hide_symbols"),
|
||||
pick: |settings_content| {
|
||||
settings_content
|
||||
.outline_panel
|
||||
.as_ref()?
|
||||
.multi_buffer_hide_symbols
|
||||
.as_ref()
|
||||
},
|
||||
write: |settings_content, value, _| {
|
||||
settings_content
|
||||
.outline_panel
|
||||
.get_or_insert_default()
|
||||
.multi_buffer_hide_symbols = value;
|
||||
},
|
||||
}),
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -5817,7 +5817,8 @@ You can define these in user or project settings; project settings are merged on
|
||||
},
|
||||
"scrollbar": {
|
||||
"show": null
|
||||
}
|
||||
},
|
||||
"multi_buffer_hide_symbols": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -608,7 +608,8 @@ See [Terminal settings](./reference/all-settings.md#terminal) for additional non
|
||||
"auto_fold_dirs": true, // Fold dirs with single subdir
|
||||
"scrollbar": { // Project panel scrollbar settings
|
||||
"show": null // Show/hide: (auto, system, always, never)
|
||||
}
|
||||
},
|
||||
"multi_buffer_hide_symbols": false // Hide symbols in multi-buffer views (show only files)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user