From 780ece551e58fcd6cebc4fb7af727bdf54826945 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 1 May 2023 17:06:05 +0200 Subject: [PATCH] Defer hiding the dock and going back/forward when Pane is on the stack --- crates/workspace/src/pane.rs | 8 +++++--- crates/workspace/src/toolbar.rs | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 2631f72fd4..8bd42fed04 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1645,9 +1645,11 @@ impl Pane { cx, |this, cx| { if let Some(workspace) = this.workspace.upgrade(cx) { - workspace.update(cx, |workspace, cx| { - Dock::hide_dock(workspace, &Default::default(), cx) - }) + cx.window_context().defer(move |cx| { + workspace.update(cx, |workspace, cx| { + Dock::hide_dock(workspace, &Default::default(), cx) + }) + }); } }, None, diff --git a/crates/workspace/src/toolbar.rs b/crates/workspace/src/toolbar.rs index a940bd09b2..eac9963d38 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -138,10 +138,13 @@ impl View for Toolbar { .upgrade(cx) .and_then(|pane| pane.read(cx).workspace().upgrade(cx)) { - workspace.update(cx, |workspace, cx| { - Pane::go_back(workspace, Some(pane.clone()), cx) - .detach_and_log_err(cx); - }); + let pane = pane.clone(); + cx.window_context().defer(move |cx| { + workspace.update(cx, |workspace, cx| { + Pane::go_back(workspace, Some(pane.clone()), cx) + .detach_and_log_err(cx); + }); + }) } } }, @@ -163,9 +166,12 @@ impl View for Toolbar { .upgrade(cx) .and_then(|pane| pane.read(cx).workspace().upgrade(cx)) { - workspace.update(cx, |workspace, cx| { - Pane::go_forward(workspace, Some(pane.clone()), cx) - .detach_and_log_err(cx); + let pane = pane.clone(); + cx.window_context().defer(move |cx| { + workspace.update(cx, |workspace, cx| { + Pane::go_forward(workspace, Some(pane.clone()), cx) + .detach_and_log_err(cx); + }); }); } }