From ce7074c8831b44ca3fb77b1e2a881c4261cc4b1f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 9 Jul 2024 19:10:20 +0200 Subject: [PATCH] Fix panic when opening the same context twice (#14004) Release Notes: - Fixed a crash that occurred when opening the same context twice in the assistant panel (preview-only). --- crates/assistant/src/assistant_panel.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index 5ba8447087..36899fb6fd 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -616,8 +616,9 @@ impl AssistantPanel { .filter(|editor| editor.read(cx).context.read(cx).path.as_ref() == Some(&path)) }); if let Some(existing_context) = existing_context { - self.show_context(existing_context, cx); - return Task::ready(Ok(())); + return cx.spawn(|this, mut cx| async move { + this.update(&mut cx, |this, cx| this.show_context(existing_context, cx)) + }); } let saved_context = self.context_store.read(cx).load(path.clone(), cx);