diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 0f37e06f43..186805d12c 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -425,15 +425,22 @@ fn main() { app.on_reopen(move |cx| { if let Some(app_state) = AppState::try_global(cx).and_then(|app_state| app_state.upgrade()) { - cx.spawn({ - let app_state = app_state.clone(); - |mut cx| async move { - if let Err(e) = restore_or_create_workspace(app_state, &mut cx).await { - fail_to_open_window_async(e, &mut cx) + let ui_has_launched = cx + .try_global::() + .map(|mode| matches!(mode, AppMode::Ui)) + .unwrap_or(false); + + if ui_has_launched { + cx.spawn({ + let app_state = app_state.clone(); + |mut cx| async move { + if let Err(e) = restore_or_create_workspace(app_state, &mut cx).await { + fail_to_open_window_async(e, &mut cx) + } } - } - }) - .detach(); + }) + .detach(); + } } });