Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix for toggles on the Welcome page (#8159)

Uladzislau Kaminski602fd58929fa
diff --git a/crates/settings/src/settings_file.rs b/crates/settings/src/settings_file.rs
index 7304fc5f1ee..b0cc8ade5cc 100644
--- a/crates/settings/src/settings_file.rs
+++ b/crates/settings/src/settings_file.rs
@@ -116,13 +116,20 @@ pub fn update_settings_file<T: Settings>(
store.new_text_for_update::<T>(old_text, update)
})?;
let initial_path = paths::SETTINGS.as_path();
- let resolved_path = fs
- .canonicalize(initial_path)
- .await
- .with_context(|| format!("Failed to canonicalize settings path {:?}", initial_path))?;
- fs.atomic_write(resolved_path.clone(), new_text)
- .await
- .with_context(|| format!("Failed to write settings to file {:?}", resolved_path))?;
+ if !fs.is_file(initial_path).await {
+ fs.atomic_write(initial_path.to_path_buf(), new_text)
+ .await
+ .with_context(|| format!("Failed to write settings to file {:?}", initial_path))?;
+ } else {
+ let resolved_path = fs.canonicalize(initial_path).await.with_context(|| {
+ format!("Failed to canonicalize settings path {:?}", initial_path)
+ })?;
+
+ fs.atomic_write(resolved_path.clone(), new_text)
+ .await
+ .with_context(|| format!("Failed to write settings to file {:?}", resolved_path))?;
+ }
+
anyhow::Ok(())
})
.detach_and_log_err(cx);