Create the settings file if needed when opening it via command
This commit is contained in:
parent
9a6819b899
commit
bdb39f6247
1 changed files with 20 additions and 5 deletions
|
@ -49,7 +49,26 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
||||||
settings_tx.borrow_mut().buffer_font_size = new_size;
|
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<Workspace>| {
|
||||||
|
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);
|
workspace::lsp_status::init(cx);
|
||||||
|
|
||||||
|
@ -60,10 +79,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_settings(workspace: &mut Workspace, _: &OpenSettings, cx: &mut ViewContext<Workspace>) {
|
|
||||||
workspace.open_paths(&[SETTINGS_PATH.clone()], cx).detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn build_workspace(
|
pub fn build_workspace(
|
||||||
project: ModelHandle<Project>,
|
project: ModelHandle<Project>,
|
||||||
app_state: &Arc<AppState>,
|
app_state: &Arc<AppState>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue