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<T>` so any intent in overriding values is
captured.

This PR follows the same `*Settings<FileContent = *SettingsContent>`
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
This commit is contained in:
Andres Suarez 2025-05-20 03:56:24 -04:00 committed by GitHub
parent e9c9a8a269
commit ca513f52bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,52 +3,48 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsSources}; use settings::{Settings, SettingsSources};
#[derive(Copy, Clone, Serialize, Deserialize, JsonSchema, Debug)] #[derive(Copy, Clone, Deserialize, Debug)]
#[serde(default)]
pub struct TitleBarSettings { pub struct TitleBarSettings {
/// Whether to show the branch icon beside branch switcher in the title bar.
///
/// Default: false
pub show_branch_icon: bool, pub show_branch_icon: bool,
/// Whether to show onboarding banners in the title bar.
///
/// Default: true
pub show_onboarding_banner: bool, pub show_onboarding_banner: bool,
/// Whether to show user avatar in the title bar.
///
/// Default: true
pub show_user_picture: bool, pub show_user_picture: bool,
/// Whether to show the branch name button in the titlebar.
///
/// Default: true
pub show_branch_name: bool, pub show_branch_name: bool,
/// Whether to show the project host and name in the titlebar.
///
/// Default: true
pub show_project_items: bool, pub show_project_items: bool,
/// Whether to show the sign in button in the title bar.
///
/// Default: true
pub show_sign_in: bool, pub show_sign_in: bool,
} }
impl Default for TitleBarSettings { #[derive(Copy, Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
fn default() -> Self { pub struct TitleBarSettingsContent {
Self { /// Whether to show the branch icon beside branch switcher in the title bar.
show_branch_icon: false, ///
show_onboarding_banner: true, /// Default: false
show_user_picture: true, pub show_branch_icon: Option<bool>,
show_branch_name: true, /// Whether to show onboarding banners in the title bar.
show_project_items: true, ///
show_sign_in: true, /// Default: true
} pub show_onboarding_banner: Option<bool>,
} /// Whether to show user avatar in the title bar.
///
/// Default: true
pub show_user_picture: Option<bool>,
/// Whether to show the branch name button in the titlebar.
///
/// Default: true
pub show_branch_name: Option<bool>,
/// Whether to show the project host and name in the titlebar.
///
/// Default: true
pub show_project_items: Option<bool>,
/// Whether to show the sign in button in the title bar.
///
/// Default: true
pub show_sign_in: Option<bool>,
} }
impl Settings for TitleBarSettings { impl Settings for TitleBarSettings {
const KEY: Option<&'static str> = Some("title_bar"); const KEY: Option<&'static str> = Some("title_bar");
type FileContent = Self; type FileContent = TitleBarSettingsContent;
fn load(sources: SettingsSources<Self::FileContent>, _: &mut gpui::App) -> anyhow::Result<Self> fn load(sources: SettingsSources<Self::FileContent>, _: &mut gpui::App) -> anyhow::Result<Self>
where where