Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Avoid panic by only restoring workspace if UI has launched (#18386)

Thorsten Ball140d70289e54
diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs
index 0f37e06f438..186805d12cd 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::<AppMode>()
+ .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();
+ }
}
});