diff --git a/assets/settings/default.json b/assets/settings/default.json index b2a7fce83af3145c22b1e71e4c830a4b8ec94596..a5c42bba38d6b6e2f5e995c6afee0c8fd561538c 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -372,6 +372,8 @@ "default_width": 240, // Where to dock the project panel. Can be 'left' or 'right'. "dock": "left", + // Spacing between worktree entries in the project panel. Can be 'comfortable' or 'standard'. + "entry_spacing": "comfortable", // Whether to show file icons in the project panel. "file_icons": true, // Whether to show folder icons or chevrons for directories in the project panel. diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 886ac953794b4fcfe2e004c107a46c784f563db7..1eccfc9e1b409e00118bc6efc3701e8957164bcb 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -54,8 +54,8 @@ use std::{ use theme::ThemeSettings; use ui::{ prelude::*, v_flex, ContextMenu, DecoratedIcon, Icon, IconDecoration, IconDecorationKind, - IndentGuideColors, IndentGuideLayout, KeyBinding, Label, ListItem, Scrollbar, ScrollbarState, - Tooltip, + IndentGuideColors, IndentGuideLayout, KeyBinding, Label, ListItem, ListItemSpacing, Scrollbar, + ScrollbarState, Tooltip, }; use util::{maybe, paths::compare_paths, ResultExt, TakeUntilExt, TryFutureExt}; use workspace::{ @@ -3447,6 +3447,12 @@ impl ProjectPanel { ListItem::new(entry_id.to_proto() as usize) .indent_level(depth) .indent_step_size(px(settings.indent_size)) + .spacing(match settings.entry_spacing { + project_panel_settings::EntrySpacing::Comfortable => ListItemSpacing::Dense, + project_panel_settings::EntrySpacing::Standard => { + ListItemSpacing::ExtraDense + } + }) .selectable(false) .when_some(canonical_path, |this, path| { this.end_slot::( diff --git a/crates/project_panel/src/project_panel_settings.rs b/crates/project_panel/src/project_panel_settings.rs index 92ea7cea2d52edf311d7a987002e37c4f1065999..bf16a9688fe5729af8e4b42507fcf385cb91f08b 100644 --- a/crates/project_panel/src/project_panel_settings.rs +++ b/crates/project_panel/src/project_panel_settings.rs @@ -18,11 +18,22 @@ pub enum ShowIndentGuides { Never, } +#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +pub enum EntrySpacing { + /// Comfortable spacing of entries. + #[default] + Comfortable, + /// The standard spacing of entries. + Standard, +} + #[derive(Deserialize, Debug, Clone, Copy, PartialEq)] pub struct ProjectPanelSettings { pub button: bool, pub default_width: Pixels, pub dock: ProjectPanelDockPosition, + pub entry_spacing: EntrySpacing, pub file_icons: bool, pub folder_icons: bool, pub git_status: bool, @@ -90,6 +101,10 @@ pub struct ProjectPanelSettingsContent { /// /// Default: left pub dock: Option, + /// Spacing between worktree entries in the project panel. + /// + /// Default: comfortable + pub entry_spacing: Option, /// Whether to show file icons in the project panel. /// /// Default: true diff --git a/crates/ui/src/components/list/list_item.rs b/crates/ui/src/components/list/list_item.rs index a33916380f0c3f53b521c2c7613f0ce050dc961c..e9fb9f9243289a581a33d4c79e344b443a06c359 100644 --- a/crates/ui/src/components/list/list_item.rs +++ b/crates/ui/src/components/list/list_item.rs @@ -11,6 +11,7 @@ use crate::{prelude::*, Disclosure}; pub enum ListItemSpacing { #[default] Dense, + ExtraDense, Sparse, } @@ -219,6 +220,7 @@ impl RenderOnce for ListItem { .px(DynamicSpacing::Base06.rems(cx)) .map(|this| match self.spacing { ListItemSpacing::Dense => this, + ListItemSpacing::ExtraDense => this.py_neg_px(), ListItemSpacing::Sparse => this.py_1(), }) .when(self.inset && !self.disabled, |this| { diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 25f0823fbd9ad54ee3deb5377274f6ebb23368dd..ede2717cb9545ae954492cf52f47d05df245e27d 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -2262,6 +2262,7 @@ Run the `theme selector: toggle` action in the command palette to see a current "button": true, "default_width": 240, "dock": "left", + "entry_spacing": "comfortable", "file_icons": true, "folder_icons": true, "git_status": true, @@ -2303,6 +2304,30 @@ Run the `theme selector: toggle` action in the command palette to see a current } ``` +### Entry Spacing + +- Description: Spacing between worktree entries +- Setting: `entry_spacing` +- Default: `comfortable` + +**Options** + +1. Comfortable entry spacing + +```json +{ + "entry_spacing": "comfortable" +} +``` + +2. Standard entry spacing + +```json +{ + "entry_spacing": "standard" +} +``` + ### Git Status - Description: Indicates newly created and updated files