Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
title_bar: Add show_worktree_name setting (#61137)
Attila Süli34bfb3842d6c
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex b7cf7019ef1..397960df19e 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -548,6 +548,8 @@"show_branch_status_icon": false,// Whether to show the branch name button in the titlebar."show_branch_name": true,+ // Whether to show the worktree name button in the titlebar.+ "show_worktree_name": true,// Whether to show the project host and name in the titlebar."show_project_items": true,// Whether to show onboarding banners in the titlebar.diff --git a/crates/settings_content/src/title_bar.rs b/crates/settings_content/src/title_bar.rsindex 34b3e82aff1..74f406e8abe 100644--- a/crates/settings_content/src/title_bar.rs+++ b/crates/settings_content/src/title_bar.rs@@ -99,6 +99,10 @@ pub struct TitleBarSettingsContent {////// Default: truepub show_branch_name: Option<bool>,+ /// Whether to show the worktree name button in the titlebar.+ ///+ /// Default: true+ pub show_worktree_name: Option<bool>,/// Whether to show the project host and name in the titlebar.////// Default: truediff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rsindex 13939e246b6..8c2c9b20c54 100644--- a/crates/settings_ui/src/page_data.rs+++ b/crates/settings_ui/src/page_data.rs@@ -3989,7 +3989,7 @@ fn window_and_layout_page() -> SettingsPage {]}- fn title_bar_section() -> [SettingsPageItem; 10] {+ fn title_bar_section() -> [SettingsPageItem; 11] {[SettingsPageItem::SectionHeader("Title Bar"),SettingsPageItem::SettingItem(SettingItem {@@ -4038,6 +4038,29 @@ fn window_and_layout_page() -> SettingsPage {metadata: None,files: USER,}),+ SettingsPageItem::SettingItem(SettingItem {+ title: "Show Worktree Name",+ description: "Show the worktree name button in the titlebar.",+ field: Box::new(SettingField {+ organization_override: None,+ json_path: Some("title_bar.show_worktree_name"),+ pick: |settings_content| {+ settings_content+ .title_bar+ .as_ref()?+ .show_worktree_name+ .as_ref()+ },+ write: |settings_content, value, _| {+ settings_content+ .title_bar+ .get_or_insert_default()+ .show_worktree_name = value;+ },+ }),+ metadata: None,+ files: USER,+ }),SettingsPageItem::SettingItem(SettingItem {title: "Show Project Items",description: "Show the project host and name in the titlebar.",diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rsindex f7ccc57ae3a..52bd8104603 100644--- a/crates/title_bar/src/title_bar.rs+++ b/crates/title_bar/src/title_bar.rs@@ -988,7 +988,7 @@ impl TitleBar {worktree_label.clone()};- let worktree_button = {+ let worktree_button = settings.show_worktree_name.then(|| {let project = self.project.clone();let workspace_handle = workspace.downgrade();PopoverMenu::new("worktree-picker-menu")@@ -1022,7 +1022,7 @@ impl TitleBar {},).anchor(gpui::Anchor::TopLeft)- };+ });let branch_picker = branch_name.and_then(|branch_name| {settings.show_branch_name.then(|| {@@ -1084,19 +1084,25 @@ impl TitleBar {})});+ if worktree_button.is_none() && branch_picker.is_none() {+ return None;+ }++ let show_separator = worktree_button.is_some() && branch_picker.is_some();+Some(h_flex().gap_px()- .child(worktree_button)- .when_some(branch_picker, |this, branch_picker| {+ .children(worktree_button)+ .when(show_separator, |this| {this.child(Label::new("/").size(LabelSize::Small).color(Color::Muted).alpha(0.25),)- .child(branch_picker)})+ .children(branch_picker).into_any_element(),)}diff --git a/crates/title_bar/src/title_bar_settings.rs b/crates/title_bar/src/title_bar_settings.rsindex c81c271b355..fac95319487 100644--- a/crates/title_bar/src/title_bar_settings.rs+++ b/crates/title_bar/src/title_bar_settings.rs@@ -7,6 +7,7 @@ pub struct TitleBarSettings {pub show_onboarding_banner: bool,pub show_user_picture: bool,pub show_branch_name: bool,+ pub show_worktree_name: bool,pub show_project_items: bool,pub show_sign_in: bool,pub show_user_menu: bool,@@ -22,6 +23,7 @@ impl Settings for TitleBarSettings {show_onboarding_banner: content.show_onboarding_banner.unwrap(),show_user_picture: content.show_user_picture.unwrap(),show_branch_name: content.show_branch_name.unwrap(),+ show_worktree_name: content.show_worktree_name.unwrap(),show_project_items: content.show_project_items.unwrap(),show_sign_in: content.show_sign_in.unwrap(),show_user_menu: content.show_user_menu.unwrap(),diff --git a/docs/src/reference/all-settings.md b/docs/src/reference/all-settings.mdindex 25690087166..13123caf5bc 100644--- a/docs/src/reference/all-settings.md+++ b/docs/src/reference/all-settings.md@@ -4943,6 +4943,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a"title_bar": {"show_branch_status_icon": false,"show_branch_name": true,+ "show_worktree_name": true,"show_project_items": true,"show_onboarding_banner": true,"show_user_picture": true,@@ -4958,6 +4959,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a- `show_branch_status_icon`: Whether to show git status indicators on the branch icon in the titlebar- `show_branch_name`: Whether to show the branch name button in the titlebar+- `show_worktree_name`: Whether to show the worktree name button in the titlebar- `show_project_items`: Whether to show the project host and name in the titlebar- `show_onboarding_banner`: Whether to show onboarding banners in the titlebar- `show_user_picture`: Whether to show user picture in the titlebardiff --git a/docs/src/visual-customization.md b/docs/src/visual-customization.mdindex b3f9131ca9a..a12399e6054 100644--- a/docs/src/visual-customization.md+++ b/docs/src/visual-customization.md@@ -130,6 +130,7 @@ To disable this behavior use:"title_bar": {"show_branch_status_icon": false, // Show git status on branch icon"show_branch_name": true, // Show/hide branch name+ "show_worktree_name": true, // Show/hide worktree name"show_project_items": true, // Show/hide project host and name"show_onboarding_banner": true, // Show/hide onboarding banners"show_user_picture": true, // Show/hide user avatar