diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 43d37b6d9829aa57358e21d4107dba8dc629c0f3..c093cfd2a7473b55746fc36048aa628dd5acb512 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -49,7 +49,26 @@ pub fn init(app_state: &Arc, cx: &mut gpui::MutableAppContext) { settings_tx.borrow_mut().buffer_font_size = new_size; } }); - cx.add_action(open_settings); + + cx.add_action({ + let fs = app_state.fs.clone(); + move |_: &mut Workspace, _: &OpenSettings, cx: &mut ViewContext| { + let fs = fs.clone(); + cx.spawn(move |workspace, mut cx| async move { + if !fs.is_file(&SETTINGS_PATH).await { + fs.create_dir(&ROOT_PATH).await?; + fs.create_file(&SETTINGS_PATH, Default::default()).await?; + } + workspace + .update(&mut cx, |workspace, cx| { + workspace.open_paths(&[SETTINGS_PATH.clone()], cx) + }) + .await; + Ok::<_, anyhow::Error>(()) + }) + .detach_and_log_err(cx); + } + }); workspace::lsp_status::init(cx); @@ -60,10 +79,6 @@ pub fn init(app_state: &Arc, cx: &mut gpui::MutableAppContext) { ]) } -fn open_settings(workspace: &mut Workspace, _: &OpenSettings, cx: &mut ViewContext) { - workspace.open_paths(&[SETTINGS_PATH.clone()], cx).detach(); -} - pub fn build_workspace( project: ModelHandle, app_state: &Arc,