mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Fix spurious setting error logs on non-existent setting keys
This commit is contained in:
parent
fb11c3e4bf
commit
e32233c826
@ -339,7 +339,7 @@ pub struct TelemetrySettings {
|
|||||||
pub metrics: bool,
|
pub metrics: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Default, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct TelemetrySettingsContent {
|
pub struct TelemetrySettingsContent {
|
||||||
pub diagnostics: Option<bool>,
|
pub diagnostics: Option<bool>,
|
||||||
pub metrics: Option<bool>,
|
pub metrics: Option<bool>,
|
||||||
|
@ -10,17 +10,16 @@ pub struct EditorSettings {
|
|||||||
pub show_scrollbars: ShowScrollbars,
|
pub show_scrollbars: ShowScrollbars,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)]
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum ShowScrollbars {
|
pub enum ShowScrollbars {
|
||||||
#[default]
|
|
||||||
Auto,
|
Auto,
|
||||||
System,
|
System,
|
||||||
Always,
|
Always,
|
||||||
Never,
|
Never,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct EditorSettingsContent {
|
pub struct EditorSettingsContent {
|
||||||
pub cursor_blink: Option<bool>,
|
pub cursor_blink: Option<bool>,
|
||||||
pub hover_popover_enabled: Option<bool>,
|
pub hover_popover_enabled: Option<bool>,
|
||||||
|
@ -49,7 +49,7 @@ pub struct CopilotSettings {
|
|||||||
pub disabled_globs: Vec<GlobMatcher>,
|
pub disabled_globs: Vec<GlobMatcher>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct AllLanguageSettingsContent {
|
pub struct AllLanguageSettingsContent {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub features: Option<FeaturesContent>,
|
pub features: Option<FeaturesContent>,
|
||||||
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use settings::Setting;
|
use settings::Setting;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct ProjectSettings {
|
pub struct ProjectSettings {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub lsp: HashMap<Arc<str>, LspSettings>,
|
pub lsp: HashMap<Arc<str>, LspSettings>,
|
||||||
|
@ -25,7 +25,7 @@ pub trait Setting: 'static {
|
|||||||
const KEY: Option<&'static str>;
|
const KEY: Option<&'static str>;
|
||||||
|
|
||||||
/// The type that is stored in an individual JSON file.
|
/// The type that is stored in an individual JSON file.
|
||||||
type FileContent: Clone + Serialize + DeserializeOwned + JsonSchema;
|
type FileContent: Clone + Default + Serialize + DeserializeOwned + JsonSchema;
|
||||||
|
|
||||||
/// The logic for combining together values from one or more JSON files into the
|
/// The logic for combining together values from one or more JSON files into the
|
||||||
/// final value for this setting.
|
/// final value for this setting.
|
||||||
@ -460,11 +460,12 @@ impl SettingsStore {
|
|||||||
|
|
||||||
// If the global settings file changed, reload the global value for the field.
|
// If the global settings file changed, reload the global value for the field.
|
||||||
if changed_local_path.is_none() {
|
if changed_local_path.is_none() {
|
||||||
setting_value.set_global_value(setting_value.load_setting(
|
if let Some(value) = setting_value
|
||||||
&default_settings,
|
.load_setting(&default_settings, &user_settings_stack, cx)
|
||||||
&user_settings_stack,
|
.log_err()
|
||||||
cx,
|
{
|
||||||
)?);
|
setting_value.set_global_value(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reload the local values for the setting.
|
// Reload the local values for the setting.
|
||||||
@ -495,14 +496,12 @@ impl SettingsStore {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
setting_value.set_local_value(
|
if let Some(value) = setting_value
|
||||||
path.clone(),
|
.load_setting(&default_settings, &user_settings_stack, cx)
|
||||||
setting_value.load_setting(
|
.log_err()
|
||||||
&default_settings,
|
{
|
||||||
&user_settings_stack,
|
setting_value.set_local_value(path.clone(), value);
|
||||||
cx,
|
}
|
||||||
)?,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -536,7 +535,12 @@ impl<T: Setting> AnySettingValue for SettingValue<T> {
|
|||||||
|
|
||||||
fn deserialize_setting(&self, mut json: &serde_json::Value) -> Result<DeserializedSetting> {
|
fn deserialize_setting(&self, mut json: &serde_json::Value) -> Result<DeserializedSetting> {
|
||||||
if let Some(key) = T::KEY {
|
if let Some(key) = T::KEY {
|
||||||
json = json.get(key).unwrap_or(&serde_json::Value::Null);
|
if let Some(value) = json.get(key) {
|
||||||
|
json = value;
|
||||||
|
} else {
|
||||||
|
let value = T::FileContent::default();
|
||||||
|
return Ok(DeserializedSetting(Box::new(value)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let value = T::FileContent::deserialize(json)?;
|
let value = T::FileContent::deserialize(json)?;
|
||||||
Ok(DeserializedSetting(Box::new(value)))
|
Ok(DeserializedSetting(Box::new(value)))
|
||||||
@ -1126,7 +1130,7 @@ mod tests {
|
|||||||
staff: bool,
|
staff: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Default, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
struct UserSettingsJson {
|
struct UserSettingsJson {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
age: Option<u32>,
|
age: Option<u32>,
|
||||||
@ -1170,7 +1174,7 @@ mod tests {
|
|||||||
key2: String,
|
key2: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
struct MultiKeySettingsJson {
|
struct MultiKeySettingsJson {
|
||||||
key1: Option<String>,
|
key1: Option<String>,
|
||||||
key2: Option<String>,
|
key2: Option<String>,
|
||||||
@ -1203,7 +1207,7 @@ mod tests {
|
|||||||
Hour24,
|
Hour24,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
struct JournalSettingsJson {
|
struct JournalSettingsJson {
|
||||||
pub path: Option<String>,
|
pub path: Option<String>,
|
||||||
pub hour_format: Option<HourFormat>,
|
pub hour_format: Option<HourFormat>,
|
||||||
@ -1223,7 +1227,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
struct LanguageSettings {
|
struct LanguageSettings {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
languages: HashMap<String, LanguageSettingEntry>,
|
languages: HashMap<String, LanguageSettingEntry>,
|
||||||
|
@ -17,7 +17,7 @@ pub struct WorkspaceSettings {
|
|||||||
pub git: GitSettings,
|
pub git: GitSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct WorkspaceSettingsContent {
|
pub struct WorkspaceSettingsContent {
|
||||||
pub active_pane_magnification: Option<f32>,
|
pub active_pane_magnification: Option<f32>,
|
||||||
pub confirm_quit: Option<bool>,
|
pub confirm_quit: Option<bool>,
|
||||||
|
Loading…
Reference in New Issue
Block a user