Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix failed initialization of setting file in welcome experience
Mikayla Maki99257a821350
diff --git a/crates/settings/src/settings_file.rs b/crates/settings/src/settings_file.rsindex 50638205c51..3934467dcf6 100644--- a/crates/settings/src/settings_file.rs+++ b/crates/settings/src/settings_file.rs@@ -1,8 +1,9 @@use crate::{update_settings_file, watched_json::WatchedJsonFile, SettingsFileContent};use anyhow::Result;+use assets::Assets;use fs::Fs;-use gpui::MutableAppContext;-use std::{path::Path, sync::Arc};+use gpui::{AssetSource, MutableAppContext};+use std::{io::ErrorKind, path::Path, sync::Arc};// TODO: Switch SettingsFile to open a worktree and buffer for synchronization// And instant updates in the Zed editor@@ -39,7 +40,27 @@ impl SettingsFile {cx.background().spawn(async move {- let old_text = fs.load(path).await?;+ let old_text = match fs.load(path).await {+ Ok(settings) => settings,+ Err(err) => {+ if let Ok(e) = err.downcast::<std::io::Error>() {+ if e.kind() == ErrorKind::NotFound {+ std::str::from_utf8(+ Assets+ .load("settings/initial_user_settings.json")+ .unwrap()+ .as_ref(),+ )+ .unwrap()+ .to_string()+ } else {+ anyhow::bail!("Failed to load settings");+ }+ } else {+ anyhow::bail!("Failed to load settings")+ }+ }+ };let new_text = update_settings_file(old_text, current_file_content, update);