From 9162f299a7100f8f07ef46a4848a9197bef413bb Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 5 Dec 2023 00:31:14 +0000 Subject: [PATCH] Fix project panel context menu --- crates/gpui2/src/window.rs | 11 +++++++---- crates/ui2/src/components/context_menu.rs | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/gpui2/src/window.rs b/crates/gpui2/src/window.rs index 09bc2c561836f399ca4325b563494bda13cdd00c..64e58ee7e4dd5aebe06a9bf0f05dd87745cedc62 100644 --- a/crates/gpui2/src/window.rs +++ b/crates/gpui2/src/window.rs @@ -1497,10 +1497,13 @@ impl<'a> WindowContext<'a> { } pub fn bindings_for_action(&self, action: &dyn Action) -> Vec { - self.window.current_frame.dispatch_tree.bindings_for_action( - action, - &self.window.current_frame.dispatch_tree.context_stack, - ) + self.window + .previous_frame + .dispatch_tree + .bindings_for_action( + action, + &self.window.previous_frame.dispatch_tree.context_stack, + ) } pub fn bindings_for_action_in( diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rs index 27aa73b4fe35d38457301fad78a15cb4b0986b23..0d6a632db58f3d750bcd8e60cf6a9a92b5405468 100644 --- a/crates/ui2/src/components/context_menu.rs +++ b/crates/ui2/src/components/context_menu.rs @@ -24,6 +24,7 @@ pub struct ContextMenu { items: Vec, focus_handle: FocusHandle, selected_index: Option, + delayed: bool, } impl FocusableView for ContextMenu { @@ -46,6 +47,7 @@ impl ContextMenu { items: Default::default(), focus_handle: cx.focus_handle(), selected_index: None, + delayed: false, }, cx, ) @@ -165,6 +167,7 @@ impl ContextMenu { } }) { self.selected_index = Some(ix); + self.delayed = true; cx.notify(); let action = dispatched.boxed_clone(); cx.spawn(|this, mut cx| async move { @@ -205,7 +208,7 @@ impl Render for ContextMenu { .on_action(cx.listener(ContextMenu::select_prev)) .on_action(cx.listener(ContextMenu::confirm)) .on_action(cx.listener(ContextMenu::cancel)) - .map(|mut el| { + .when(!self.delayed, |mut el| { for item in self.items.iter() { if let ContextMenuItem::Entry { action: Some(action),