From f755cbbe98341b1b1857361d9e7d309c8b3e2e52 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 14 Apr 2021 14:47:18 +0200 Subject: [PATCH] Dispatch global actions only once when triggering a menu item Previously we would dispatch the same global action more than once because we would invoke `dispatch_action_any` _and_ `dispatch_global_action_any`. However, the former already takes care of going through the global action handlers when no entity in the dispatch path handled the action. --- gpui/src/app.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gpui/src/app.rs b/gpui/src/app.rs index b35c5ba0b4..cc309d58cb 100644 --- a/gpui/src/app.rs +++ b/gpui/src/app.rs @@ -141,12 +141,13 @@ impl App { { let presenter = presenter.clone(); let path = presenter.borrow().dispatch_path(ctx.as_ref()); - if ctx.dispatch_action_any(key_window_id, &path, command, arg.unwrap_or(&())) { - return; - } + ctx.dispatch_action_any(key_window_id, &path, command, arg.unwrap_or(&())); + } else { + ctx.dispatch_global_action_any(command, arg.unwrap_or(&())); } + } else { + ctx.dispatch_global_action_any(command, arg.unwrap_or(&())); } - ctx.dispatch_global_action_any(command, arg.unwrap_or(&())); })); app.0.borrow_mut().weak_self = Some(Rc::downgrade(&app.0));