From e61a5b172cc1f6c2ff9e1b5ad65a9c85828bdd61 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sat, 22 Jan 2022 13:23:08 -0700 Subject: [PATCH] Defer pane interaction when opening excerpts in diagnostics view Activating a new item causes the current item to be deactivated. We're the current item, but we're on the stack, so we panic if we try to do this synchronously. If we use defer to wait until we're off the stack it works. --- crates/diagnostics/src/diagnostics.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index eedb77c9be1fae401b1dfdf829fec775c501aa49..62fc3bf321809b6074a59552b84ec290d3c8f0f7 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -193,7 +193,10 @@ impl ProjectDiagnosticsEditor { } } - workspace.update(cx, |workspace, cx| { + // We defer the pane interaction because we ourselves are a workspace item + // and activating a new item causes the pane to call a method on us reentrantly, + // which panics if we're on the stack. + workspace.defer(cx, |workspace, cx| { for (buffer, ranges) in new_selections_by_buffer { let buffer = BufferItemHandle(buffer); if !workspace.activate_pane_for_item(&buffer, cx) {