mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Fix failed initialization of setting file in welcome experience
This commit is contained in:
parent
05f6747132
commit
99257a8213
1 changed files with 24 additions and 3 deletions
|
@ -1,8 +1,9 @@
|
||||||
use crate::{update_settings_file, watched_json::WatchedJsonFile, SettingsFileContent};
|
use crate::{update_settings_file, watched_json::WatchedJsonFile, SettingsFileContent};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use assets::Assets;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::MutableAppContext;
|
use gpui::{AssetSource, MutableAppContext};
|
||||||
use std::{path::Path, sync::Arc};
|
use std::{io::ErrorKind, path::Path, sync::Arc};
|
||||||
|
|
||||||
// TODO: Switch SettingsFile to open a worktree and buffer for synchronization
|
// TODO: Switch SettingsFile to open a worktree and buffer for synchronization
|
||||||
// And instant updates in the Zed editor
|
// And instant updates in the Zed editor
|
||||||
|
@ -39,7 +40,27 @@ impl SettingsFile {
|
||||||
|
|
||||||
cx.background()
|
cx.background()
|
||||||
.spawn(async move {
|
.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);
|
let new_text = update_settings_file(old_text, current_file_content, update);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue