Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix bug where open would offer to hang up a remote call
Mikayla Maki3594243644c2
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 65072637ac0..1c1afea4aad 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -228,16 +228,27 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {}}});- cx.add_action({+ cx.add_async_action({let app_state = Arc::downgrade(&app_state);- move |_, action: &OpenPaths, cx: &mut ViewContext<Workspace>| {- if let Some(app_state) = app_state.upgrade() {- let window_id = cx.window_id();- let action = action.clone();- cx.as_mut().defer(move |cx| {- open_paths(&action.paths, &app_state, Some(window_id), cx).detach();- })+ move |workspace, action: &OpenPaths, cx: &mut ViewContext<Workspace>| {+ if !workspace.project().read(cx).is_local() {+ cx.propagate_action();+ return None;}++ let app_state = app_state.upgrade()?;+ let window_id = cx.window_id();+ let action = action.clone();+ let close = workspace.prepare_to_close(false, cx);++ Some(cx.spawn_weak(|_, mut cx| async move {+ let can_close = close.await?;+ if can_close {+ cx.update(|cx| open_paths(&action.paths, &app_state, Some(window_id), cx))+ .await;+ }+ Ok(())+ }))}});