mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 02:37:21 +00:00
Always prevent window from closing and manually invoke Workspace::close
This ensures we ask the user to save their state if there are unsaved changes.
This commit is contained in:
parent
06033d7fa9
commit
d9b5357234
2 changed files with 12 additions and 1 deletions
|
@ -907,7 +907,11 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
fn close(&mut self, _: &CloseWindow, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
|
||||
pub fn close(
|
||||
&mut self,
|
||||
_: &CloseWindow,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<Task<Result<()>>> {
|
||||
let prepare = self.prepare_to_close(cx);
|
||||
Some(cx.spawn(|this, mut cx| async move {
|
||||
if prepare.await? {
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue