Detailed changes
@@ -8,7 +8,6 @@ use gpui::{
use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};
use paths::remote_servers_dir;
use release_channel::{AppCommitSha, ReleaseChannel};
-use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsContent, SettingsStore};
use smol::{fs, io::AsyncReadExt};
@@ -191,7 +191,7 @@ pub struct TitleBarSettingsContent {
/// Controls when the title bar is visible: "always" | "never" | "hide_in_full_screen".
///
/// Default: "always"
- pub show: Option<TitleBarVisibilityContent>,
+ pub show: Option<TitleBarVisibility>,
/// Whether to show the branch icon beside branch switcher in the title bar.
///
/// Default: false
@@ -224,7 +224,7 @@ pub struct TitleBarSettingsContent {
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
-pub enum TitleBarVisibilityContent {
+pub enum TitleBarVisibility {
Always,
Never,
HideInFullScreen,
@@ -1050,7 +1050,7 @@ mod tests {
use std::num::NonZeroU32;
use crate::{
- TitleBarSettingsContent, TitleBarVisibilityContent, VsCodeSettingsSource, default_settings,
+ TitleBarSettingsContent, TitleBarVisibility, VsCodeSettingsSource, default_settings,
settings_content::LanguageSettingsContent, test_settings,
};
@@ -1081,7 +1081,7 @@ mod tests {
#[derive(Debug, PartialEq)]
struct TitleBarSettings {
- show: TitleBarVisibilityContent,
+ show: TitleBarVisibility,
show_branch_name: bool,
}
@@ -1105,8 +1105,8 @@ mod tests {
let mut show = None;
vscode.enum_setting("window.titleBarStyle", &mut show, |value| match value {
- "never" => Some(TitleBarVisibilityContent::Never),
- "always" => Some(TitleBarVisibilityContent::Always),
+ "never" => Some(TitleBarVisibility::Never),
+ "always" => Some(TitleBarVisibility::Always),
_ => None,
});
if let Some(show) = show {
@@ -1163,7 +1163,7 @@ mod tests {
);
assert_eq!(
store.get::<TitleBarSettings>(None).show,
- TitleBarVisibilityContent::Always
+ TitleBarVisibility::Always
);
store
@@ -1184,7 +1184,7 @@ mod tests {
);
assert_eq!(
store.get::<TitleBarSettings>(None).show,
- TitleBarVisibilityContent::Never
+ TitleBarVisibility::Never
);
// todo!()
@@ -1253,7 +1253,7 @@ mod tests {
path: Path::new("/root2/something")
})),
&TitleBarSettings {
- show: TitleBarVisibilityContent::Never,
+ show: TitleBarVisibility::Never,
show_branch_name: true,
}
);
@@ -1274,7 +1274,7 @@ mod tests {
);
assert_eq!(
store.get::<TitleBarSettings>(None).show,
- TitleBarVisibilityContent::Always,
+ TitleBarVisibility::Always,
);
}
@@ -1402,7 +1402,7 @@ mod tests {
}"#
.unindent(),
|settings| {
- settings.title_bar.as_mut().unwrap().show = Some(TitleBarVisibilityContent::Never);
+ settings.title_bar.as_mut().unwrap().show = Some(TitleBarVisibility::Never);
},
r#"{
"title_bar": { "show": "never", "name": "Max" }
@@ -1594,7 +1594,7 @@ mod tests {
assert_eq!(
store.get::<TitleBarSettings>(None),
&TitleBarSettings {
- show: TitleBarVisibilityContent::Never,
+ show: TitleBarVisibility::Never,
show_branch_name: true,
}
);
@@ -1615,7 +1615,7 @@ mod tests {
assert_eq!(
store.get::<TitleBarSettings>(None),
&TitleBarSettings {
- show: TitleBarVisibilityContent::Always,
+ show: TitleBarVisibility::Always,
show_branch_name: true, // Staff from global settings
}
);
@@ -1,15 +1,7 @@
-use db::anyhow;
-use schemars::JsonSchema;
-use serde::{Deserialize, Serialize};
-use settings::{Settings, SettingsContent, SettingsKey, SettingsSources, SettingsUi};
-
-#[derive(Copy, Clone, Serialize, Deserialize, JsonSchema, Debug, SettingsUi)]
-#[serde(rename_all = "snake_case")]
-pub enum TitleBarVisibility {
- Always,
- Never,
- HideInFullScreen,
-}
+pub use settings::TitleBarVisibility;
+use settings::{Settings, SettingsContent};
+use ui::App;
+use util::MergeFrom;
#[derive(Copy, Clone, Debug)]
pub struct TitleBarSettings {
@@ -24,35 +16,37 @@ pub struct TitleBarSettings {
}
impl Settings for TitleBarSettings {
- fn from_defaults(s: &SettingsContent) -> Option<Self> {
- let content = s.title_bar?;
+ fn from_defaults(s: &SettingsContent, _: &mut App) -> Self {
+ let content = s.title_bar.clone().unwrap();
TitleBarSettings {
- show: content.show?,
- show_branch_icon: content.show_branch_icon?,
- show_onboarding_banner: content.show_onboarding_banner?,
- show_user_picture: content.show_user_picture?,
- show_branch_name: content.show_branch_name?,
- show_project_items: content.show_project_items?,
- show_sign_in: content.show_sign_in?,
- show_menus: content.show_menus?,
+ show: content.show.unwrap(),
+ show_branch_icon: content.show_branch_icon.unwrap(),
+ 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_project_items: content.show_project_items.unwrap(),
+ show_sign_in: content.show_sign_in.unwrap(),
+ show_menus: content.show_menus.unwrap(),
}
}
fn refine(&mut self, s: &SettingsContent, _: &mut App) {
- let Some(content) = s.title_bar else {
+ let Some(content) = &s.title_bar else {
return;
};
- self.show.refine(&content.show);
- self.show_branch_icon.refine(content.show_branch_icon);
+ self.show.merge_from(&content.show);
+ self.show_branch_icon.merge_from(&content.show_branch_icon);
self.show_onboarding_banner
- .refine(content.show_onboarding_banner);
- self.show_user_picture.refine(content.show_user_picture);
- self.show_branch_name.refine(content.show_branch_name);
- self.show_project_items.refine(content.show_project_items);
- self.show_sign_in.refine(content.show_sign_in);
- self.show_menus.refine(content.show_menus);
+ .merge_from(&content.show_onboarding_banner);
+ self.show_user_picture
+ .merge_from(&content.show_user_picture);
+ self.show_branch_name.merge_from(&content.show_branch_name);
+ self.show_project_items
+ .merge_from(&content.show_project_items);
+ self.show_sign_in.merge_from(&content.show_sign_in);
+ self.show_menus.merge_from(&content.show_menus);
}
- fn import_from_vscode(_: &settings::VsCodeSettings, _: &mut Self::FileContent) {}
+ fn import_from_vscode(_: &settings::VsCodeSettings, _: &mut SettingsContent) {}
}