Fix for toggles on the Welcome page (#8159)

Release Notes:

The issue is that when welcome page appears settings.json file is not
created yet. So the idea of this fix is to create the file in case it is
not there yet.

- Fixed the toggles on the welcome screen not working if no settings
file exists yet.
([#8153](https://github.com/zed-industries/zed/issues/8153)).

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
Uladzislau Kaminski
2024-02-23 18:24:04 +01:00
committed by GitHub
co-authored by Thorsten Ball Marshall
parent ed3bb68206
commit 602fd58929
+14 -7
View File
@@ -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);