From ca513f52bf31286154e3a3dd84c5fc3e8f939cab Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Tue, 20 May 2025 03:56:24 -0400 Subject: [PATCH] title_bar: Fix config merging to respect priority (#30980) This is a follow-up to #30450 so that _global_ `title_bar` configs shadow _defaults_. The way `SettingsSources::json_merge` works is by considering non-json-nulls as values to propagate. So it's important that configs be `Option` so any intent in overriding values is captured. This PR follows the same `*Settings` pattern used throughout to keep the `Option`s in the "settings content" type with the finalized values in the "settings" type. Release Notes: - N/A --- crates/title_bar/src/title_bar_settings.rs | 40 ++++++++++------------ 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/crates/title_bar/src/title_bar_settings.rs b/crates/title_bar/src/title_bar_settings.rs index b6695bf6fb30e37aeb51137c02600e5aec8ec45e..cb8f3fa56566ec4ff0a9728300147cc03829978e 100644 --- a/crates/title_bar/src/title_bar_settings.rs +++ b/crates/title_bar/src/title_bar_settings.rs @@ -3,52 +3,48 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use settings::{Settings, SettingsSources}; -#[derive(Copy, Clone, Serialize, Deserialize, JsonSchema, Debug)] -#[serde(default)] +#[derive(Copy, Clone, Deserialize, Debug)] pub struct TitleBarSettings { + pub show_branch_icon: bool, + pub show_onboarding_banner: bool, + pub show_user_picture: bool, + pub show_branch_name: bool, + pub show_project_items: bool, + pub show_sign_in: bool, +} + +#[derive(Copy, Clone, Default, Serialize, Deserialize, JsonSchema, Debug)] +pub struct TitleBarSettingsContent { /// Whether to show the branch icon beside branch switcher in the title bar. /// /// Default: false - pub show_branch_icon: bool, + pub show_branch_icon: Option, /// Whether to show onboarding banners in the title bar. /// /// Default: true - pub show_onboarding_banner: bool, + pub show_onboarding_banner: Option, /// Whether to show user avatar in the title bar. /// /// Default: true - pub show_user_picture: bool, + pub show_user_picture: Option, /// Whether to show the branch name button in the titlebar. /// /// Default: true - pub show_branch_name: bool, + pub show_branch_name: Option, /// Whether to show the project host and name in the titlebar. /// /// Default: true - pub show_project_items: bool, + pub show_project_items: Option, /// Whether to show the sign in button in the title bar. /// /// Default: true - pub show_sign_in: bool, -} - -impl Default for TitleBarSettings { - fn default() -> Self { - Self { - show_branch_icon: false, - show_onboarding_banner: true, - show_user_picture: true, - show_branch_name: true, - show_project_items: true, - show_sign_in: true, - } - } + pub show_sign_in: Option, } impl Settings for TitleBarSettings { const KEY: Option<&'static str> = Some("title_bar"); - type FileContent = Self; + type FileContent = TitleBarSettingsContent; fn load(sources: SettingsSources, _: &mut gpui::App) -> anyhow::Result where