Fix panic on quit

This commit is contained in:
Conrad Irwin 2023-11-27 15:32:26 -07:00
parent 107c3d7f67
commit 47b4d9942f
3 changed files with 21 additions and 6 deletions

View file

@ -166,12 +166,17 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
// vim::observe_keystrokes(cx);
// cx.on_window_should_close(|workspace, cx| {
// if let Some(task) = workspace.close(&Default::default(), cx) {
// task.detach_and_log_err(cx);
// }
// false
// });
let handle = cx.view().downgrade();
cx.on_window_should_close(move |cx| {
handle
.update(cx, |workspace, cx| {
if let Some(task) = workspace.close(&Default::default(), cx) {
task.detach_and_log_err(cx);
}
false
})
.unwrap_or(true)
});
cx.spawn(|workspace_handle, mut cx| async move {
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());