mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-10 20:29:05 +00:00
Don't log JSON parse errors with no settings (#11459)
Release Notes: - Silenced error messages on startup when no settings/keymap files exist.
This commit is contained in:
parent
2e6d044bac
commit
f3fffc25c4
2 changed files with 13 additions and 4 deletions
|
@ -47,6 +47,9 @@ impl KeymapFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(content: &str) -> Result<Self> {
|
pub fn parse(content: &str) -> Result<Self> {
|
||||||
|
if content.is_empty() {
|
||||||
|
return Ok(Self::default());
|
||||||
|
}
|
||||||
parse_json_with_comments::<Self>(content)
|
parse_json_with_comments::<Self>(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -430,7 +430,11 @@ impl SettingsStore {
|
||||||
user_settings_content: &str,
|
user_settings_content: &str,
|
||||||
cx: &mut AppContext,
|
cx: &mut AppContext,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let settings: serde_json::Value = parse_json_with_comments(user_settings_content)?;
|
let settings: serde_json::Value = if user_settings_content.is_empty() {
|
||||||
|
parse_json_with_comments("{}")?
|
||||||
|
} else {
|
||||||
|
parse_json_with_comments(user_settings_content)?
|
||||||
|
};
|
||||||
if settings.is_object() {
|
if settings.is_object() {
|
||||||
self.raw_user_settings = settings;
|
self.raw_user_settings = settings;
|
||||||
self.recompute_values(None, cx)?;
|
self.recompute_values(None, cx)?;
|
||||||
|
@ -448,9 +452,11 @@ impl SettingsStore {
|
||||||
settings_content: Option<&str>,
|
settings_content: Option<&str>,
|
||||||
cx: &mut AppContext,
|
cx: &mut AppContext,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if let Some(content) = settings_content {
|
if settings_content.is_some_and(|content| !content.is_empty()) {
|
||||||
self.raw_local_settings
|
self.raw_local_settings.insert(
|
||||||
.insert((root_id, path.clone()), parse_json_with_comments(content)?);
|
(root_id, path.clone()),
|
||||||
|
parse_json_with_comments(settings_content.unwrap())?,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
self.raw_local_settings.remove(&(root_id, path.clone()));
|
self.raw_local_settings.remove(&(root_id, path.clone()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue