From 5331418f3a94e9f3d6ae9621e5e8a702415809ae Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Mon, 27 Jan 2025 21:36:33 -0300 Subject: [PATCH] pane: Add settings to hide the tab bar buttons (#23752) This PR adds the `show_tab_bar_buttons` under `tab_bar` that allows hiding the "New", "Split Pane", and "Zoom" buttons to the left of the pane tab bar. Release Notes: - Added a new `show_tab_bar_buttons` setting, under `tab_bar`, that enables hiding the pane tab bar buttons. --- assets/settings/default.json | 4 +++- crates/workspace/src/pane.rs | 23 +++++++++++++++------- crates/workspace/src/workspace_settings.rs | 5 +++++ docs/src/configuring-zed.md | 13 +++++++++++- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index ad982a7179..4650aec674 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -592,7 +592,9 @@ // Whether or not to show the tab bar in the editor "show": true, // Whether or not to show the navigation history buttons. - "show_nav_history_buttons": true + "show_nav_history_buttons": true, + /// Whether or not to show the tab bar buttons. + "show_tab_bar_buttons": true }, // Settings related to the editor's tabs "tabs": { diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index eeb810bc23..098faf8897 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -304,6 +304,7 @@ pub struct Pane { &mut Context, ) -> (Option, Option), >, + show_tab_bar_buttons: bool, _subscriptions: Vec, tab_bar_scroll_handle: ScrollHandle, /// Is None if navigation buttons are permanently turned off (and should not react to setting changes). @@ -509,6 +510,7 @@ impl Pane { .into(); (None, right_children) }), + show_tab_bar_buttons: TabBarSettings::get_global(cx).show_tab_bar_buttons, display_nav_history_buttons: Some( TabBarSettings::get_global(cx).show_nav_history_buttons, ), @@ -659,9 +661,13 @@ impl Pane { } fn settings_changed(&mut self, cx: &mut Context) { + let tab_bar_settings = TabBarSettings::get_global(cx); + if let Some(display_nav_history_buttons) = self.display_nav_history_buttons.as_mut() { - *display_nav_history_buttons = TabBarSettings::get_global(cx).show_nav_history_buttons; + *display_nav_history_buttons = tab_bar_settings.show_nav_history_buttons; } + self.show_tab_bar_buttons = tab_bar_settings.show_tab_bar_buttons; + if !PreviewTabsSettings::get_global(cx).enabled { self.preview_item_id = None; } @@ -2581,12 +2587,15 @@ impl Pane { }, ) .map(|tab_bar| { - let render_tab_buttons = self.render_tab_bar_buttons.clone(); - let (left_children, right_children) = render_tab_buttons(self, window, cx); - - tab_bar - .start_children(left_children) - .end_children(right_children) + if self.show_tab_bar_buttons { + let render_tab_buttons = self.render_tab_bar_buttons.clone(); + let (left_children, right_children) = render_tab_buttons(self, window, cx); + tab_bar + .start_children(left_children) + .end_children(right_children) + } else { + tab_bar + } }) .children(pinned_tabs.len().ne(&0).then(|| { h_flex() diff --git a/crates/workspace/src/workspace_settings.rs b/crates/workspace/src/workspace_settings.rs index 90202f5026..f6d3a176d6 100644 --- a/crates/workspace/src/workspace_settings.rs +++ b/crates/workspace/src/workspace_settings.rs @@ -147,6 +147,7 @@ pub struct WorkspaceSettingsContent { pub struct TabBarSettings { pub show: bool, pub show_nav_history_buttons: bool, + pub show_tab_bar_buttons: bool, } #[derive(Clone, Default, Serialize, Deserialize, JsonSchema)] @@ -159,6 +160,10 @@ pub struct TabBarSettingsContent { /// /// Default: true pub show_nav_history_buttons: Option, + /// Whether or not to show the tab bar buttons. + /// + /// Default: true + pub show_tab_bar_buttons: Option, } #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)] diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 163c17b2b8..41a886088c 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -714,7 +714,8 @@ List of `string` values ```json "tab_bar": { "show": true, - "show_nav_history_buttons": true + "show_nav_history_buttons": true, + "show_tab_bar_buttons": true } ``` @@ -738,6 +739,16 @@ List of `string` values `boolean` values +### Tab Bar Buttons + +- Description: Whether or not to show the tab bar buttons. +- Setting: `show_tab_bar_buttons` +- Default: `true` + +**Options** + +`boolean` values + ## Editor Tabs - Description: Configuration for the editor tabs.