From 4c92172ccac088825c8470b986159d1694787da8 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 8 Sep 2023 16:49:50 -0600 Subject: [PATCH] Partially roll back refactoring --- crates/collab/src/tests/integration_tests.rs | 4 +--- crates/workspace/src/workspace.rs | 17 ++++++----------- crates/zed/src/zed.rs | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 405956e5dbd97947fba867c744cb2e109b1d1ec0..8121b0ac91d5021e2830236c1694a24a20cff3b5 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -1530,9 +1530,7 @@ async fn test_host_disconnect( // Ensure client B is not prompted to save edits when closing window after disconnecting. let can_close = workspace_b - .update(cx_b, |workspace, cx| { - workspace.prepare_to_close(true, workspace::SaveBehavior::PromptOnWrite, cx) - }) + .update(cx_b, |workspace, cx| workspace.prepare_to_close(true, cx)) .await .unwrap(); assert!(can_close); diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index abbed1fcf0546e7960f4b58de0929616f9e6628b..f0cb94202665112484c6d9bf30a3897f787d559a 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1258,7 +1258,7 @@ impl Workspace { cx: &mut ViewContext, ) -> Option>> { let window = cx.window(); - let prepare = self.prepare_to_close(false, SaveBehavior::PromptOnWrite, cx); + let prepare = self.prepare_to_close(false, cx); Some(cx.spawn(|_, mut cx| async move { if prepare.await? { window.remove(&mut cx); @@ -1270,7 +1270,6 @@ impl Workspace { pub fn prepare_to_close( &mut self, quitting: bool, - save_behavior: SaveBehavior, cx: &mut ViewContext, ) -> Task> { let active_call = self.active_call().cloned(); @@ -1310,7 +1309,7 @@ impl Workspace { Ok(this .update(&mut cx, |this, cx| { - this.save_all_internal(save_behavior, cx) + this.save_all_internal(SaveBehavior::PromptOnWrite, cx) })? .await?) }) @@ -1407,7 +1406,7 @@ impl Workspace { let close_task = if is_remote || has_worktree || has_dirty_items { None } else { - Some(self.prepare_to_close(false, SaveBehavior::PromptOnWrite, cx)) + Some(self.prepare_to_close(false, cx)) }; let app_state = self.app_state.clone(); @@ -4102,7 +4101,7 @@ pub fn restart(_: &Restart, cx: &mut AppContext) { // If the user cancels any save prompt, then keep the app open. for window in workspace_windows { if let Some(should_close) = window.update_root(&mut cx, |workspace, cx| { - workspace.prepare_to_close(true, SaveBehavior::PromptOnWrite, cx) + workspace.prepare_to_close(true, cx) }) { if !should_close.await? { return Ok(()); @@ -4292,9 +4291,7 @@ mod tests { // When there are no dirty items, there's nothing to do. let item1 = window.add_view(cx, |_| TestItem::new()); workspace.update(cx, |w, cx| w.add_item(Box::new(item1.clone()), cx)); - let task = workspace.update(cx, |w, cx| { - w.prepare_to_close(false, SaveBehavior::PromptOnWrite, cx) - }); + let task = workspace.update(cx, |w, cx| w.prepare_to_close(false, cx)); assert!(task.await.unwrap()); // When there are dirty untitled items, prompt to save each one. If the user @@ -4309,9 +4306,7 @@ mod tests { w.add_item(Box::new(item2.clone()), cx); w.add_item(Box::new(item3.clone()), cx); }); - let task = workspace.update(cx, |w, cx| { - w.prepare_to_close(false, SaveBehavior::PromptOnWrite, cx) - }); + let task = workspace.update(cx, |w, cx| w.prepare_to_close(false, cx)); cx.foreground().run_until_parked(); window.simulate_prompt_answer(2, cx); // cancel cx.foreground().run_until_parked(); diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index c00bb7ee0d654e625e218737279075ba5363a24d..f12dc8a98bb108df5420eb769978a1587aa5b9c3 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -438,7 +438,7 @@ fn quit(_: &Quit, cx: &mut gpui::AppContext) { // If the user cancels any save prompt, then keep the app open. for window in workspace_windows { if let Some(should_close) = window.update_root(&mut cx, |workspace, cx| { - workspace.prepare_to_close(true, workspace::SaveBehavior::PromptOnWrite, cx) + workspace.prepare_to_close(true, cx) }) { if !should_close.await? { return Ok(());