
Follow-up to #30565 This PR fixes the default settings values for the `DiagnosticsSettings`. The issue here was that due to the `#[derive(Default)]`, `button` would be false by default, which unintentionally hid the diagnostics button by default. The `#[serde(default = `default_true`)]` would only apply iff the diagnostics key was already present in the user's settings. Thus, if you have ```json { "diagnostics": {...} } ``` in your settings, the button would show (given it was not disabled). However, if the key was not present, the button was not shown: Due to the derived default for the entire struct, the value would be false. This PR fixes this by implementing the default instead and moving the `#[serde(default)]` up to the level of the struct. I also did the same for the inline diagnostics settings, which already had a default impl and thus only needed the serde default on the struct instead of on all the struct fields. Lastly, I simplified the title bar settings, since the serde attributes previously had no effect anyway (deserialization happened in the `TitlebarSettingsContent`, so these attributes had no effect) and we can remove the `TitlebarSettingsContent` as well as the attributes if we implement a proper default implementation instead. Release Notes: - Fixed the diagnostics status bar button being hidden by default.
56 lines
1.5 KiB
Rust
56 lines
1.5 KiB
Rust
use db::anyhow;
|
|
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
use settings::{Settings, SettingsSources};
|
|
|
|
#[derive(Copy, Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
|
#[serde(default)]
|
|
pub struct TitleBarSettings {
|
|
/// Whether to show the branch icon beside branch switcher in the title bar.
|
|
///
|
|
/// Default: false
|
|
pub show_branch_icon: bool,
|
|
/// Whether to show onboarding banners in the title bar.
|
|
///
|
|
/// Default: true
|
|
pub show_onboarding_banner: bool,
|
|
/// Whether to show user avatar in the title bar.
|
|
///
|
|
/// Default: true
|
|
pub show_user_picture: bool,
|
|
/// Whether to show the branch name button in the titlebar.
|
|
///
|
|
/// Default: true
|
|
pub show_branch_name: bool,
|
|
/// Whether to show the project host and name in the titlebar.
|
|
///
|
|
/// Default: true
|
|
pub show_project_items: 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,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Settings for TitleBarSettings {
|
|
const KEY: Option<&'static str> = Some("title_bar");
|
|
|
|
type FileContent = Self;
|
|
|
|
fn load(sources: SettingsSources<Self::FileContent>, _: &mut gpui::App) -> anyhow::Result<Self>
|
|
where
|
|
Self: Sized,
|
|
{
|
|
sources.json_merge()
|
|
}
|
|
|
|
fn import_from_vscode(_: &settings::VsCodeSettings, _: &mut Self::FileContent) {}
|
|
}
|