diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 55da35ca858ff95acbd5aa757e43375bc71d3343..0a7c0c1e82c4a5ec2890e0b5bc24f24d1563d78a 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -907,7 +907,11 @@ impl Workspace { } } - fn close(&mut self, _: &CloseWindow, cx: &mut ViewContext) -> Option>> { + pub fn close( + &mut self, + _: &CloseWindow, + cx: &mut ViewContext, + ) -> Option>> { let prepare = self.prepare_to_close(cx); Some(cx.spawn(|this, mut cx| async move { if prepare.await? { diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index bfccd42b6bcc0fa9057b14133cd8ef47b489e46e..35981bda0b638515305c36ad82450bec9ab98d13 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -222,6 +222,13 @@ pub fn initialize_workspace( }); auto_update::notify_of_any_new_update(cx.weak_handle(), cx); + + cx.on_window_should_close(|workspace, cx| { + if let Some(task) = workspace.close(&Default::default(), cx) { + task.detach_and_log_err(cx); + } + false + }); } pub fn build_window_options() -> WindowOptions<'static> {