mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 05:00:16 +00:00
8451dba6a7
Adds a new panel: `OutlinePanel` which looks very close to project panel: <img width="256" alt="Screenshot 2024-06-10 at 23 19 05" src="https://github.com/zed-industries/zed/assets/2690773/c66e6e78-44ec-4de8-8d60-43238bb09ae9"> has similar settings and keymap (actions work in the `OutlinePanel` context and are under `outline_panel::` namespace), with two notable differences: * no "edit" actions such as cut/copy/paste/delete/etc. * directory auto folding is enabled by default Empty view: <img width="841" alt="Screenshot 2024-06-10 at 23 19 11" src="https://github.com/zed-industries/zed/assets/2690773/dc8bf37c-5a70-4fd5-9b57-76271eb7a40c"> When editor gets active, the panel displays all related files in a tree (similar to what the project panel does) and all related excerpts' outlines under each file. Same as in the project panel, directories can be expanded or collapsed, unfolded or folded; clicking file entries or outlines scrolls the buffer to the corresponding excerpt; changing editor's selection reveals the corresponding outline in the panel. The panel is applicable to any singleton buffer: <img width="1215" alt="Screenshot 2024-06-10 at 23 19 35" src="https://github.com/zed-industries/zed/assets/2690773/a087631f-5c2d-4d4d-ae25-30ab9731d528"> <img width="1728" alt="image" src="https://github.com/zed-industries/zed/assets/2690773/e4f8082c-d12d-4473-8500-e8fd1051285b"> or any multi buffer: (search multi buffer) <img width="1728" alt="Screenshot 2024-06-10 at 23 19 41" src="https://github.com/zed-industries/zed/assets/2690773/60f768a3-6716-4520-9b13-42da8fd15f50"> (diagnostics multi buffer) <img width="1728" alt="image" src="https://github.com/zed-industries/zed/assets/2690773/64e285bd-9530-4bf2-8f1f-10ee5596067c"> Release Notes: - Added an outline panel to show a "map" of the active editor
81 lines
2.4 KiB
Rust
81 lines
2.4 KiB
Rust
use anyhow;
|
|
use gpui::Pixels;
|
|
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
use settings::{Settings, SettingsSources};
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, Copy, PartialEq)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum OutlinePanelDockPosition {
|
|
Left,
|
|
Right,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
|
|
pub struct OutlinePanelSettings {
|
|
pub button: bool,
|
|
pub default_width: Pixels,
|
|
pub dock: OutlinePanelDockPosition,
|
|
pub file_icons: bool,
|
|
pub folder_icons: bool,
|
|
pub git_status: bool,
|
|
pub indent_size: f32,
|
|
pub auto_reveal_entries: bool,
|
|
pub auto_fold_dirs: bool,
|
|
}
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
|
pub struct OutlinePanelSettingsContent {
|
|
/// Whether to show the outline panel button in the status bar.
|
|
///
|
|
/// Default: true
|
|
pub button: Option<bool>,
|
|
/// Customise default width (in pixels) taken by outline panel
|
|
///
|
|
/// Default: 240
|
|
pub default_width: Option<f32>,
|
|
/// The position of outline panel
|
|
///
|
|
/// Default: left
|
|
pub dock: Option<OutlinePanelDockPosition>,
|
|
/// Whether to show file icons in the outline panel.
|
|
///
|
|
/// Default: true
|
|
pub file_icons: Option<bool>,
|
|
/// Whether to show folder icons or chevrons for directories in the outline panel.
|
|
///
|
|
/// Default: true
|
|
pub folder_icons: Option<bool>,
|
|
/// Whether to show the git status in the outline panel.
|
|
///
|
|
/// Default: true
|
|
pub git_status: Option<bool>,
|
|
/// Amount of indentation (in pixels) for nested items.
|
|
///
|
|
/// Default: 20
|
|
pub indent_size: Option<f32>,
|
|
/// Whether to reveal it in the outline panel automatically,
|
|
/// when a corresponding project entry becomes active.
|
|
/// Gitignored entries are never auto revealed.
|
|
///
|
|
/// Default: true
|
|
pub auto_reveal_entries: Option<bool>,
|
|
/// Whether to fold directories automatically
|
|
/// when directory has only one directory inside.
|
|
///
|
|
/// Default: true
|
|
pub auto_fold_dirs: Option<bool>,
|
|
}
|
|
|
|
impl Settings for OutlinePanelSettings {
|
|
const KEY: Option<&'static str> = Some("outline_panel");
|
|
|
|
type FileContent = OutlinePanelSettingsContent;
|
|
|
|
fn load(
|
|
sources: SettingsSources<Self::FileContent>,
|
|
_: &mut gpui::AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
sources.json_merge()
|
|
}
|
|
}
|