Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Add `is_action_available_in` function (#45029)
Anthony Eid3a013d8090e1
diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rsindex 36e46f6961a..c606409661e 100644--- a/crates/gpui/src/window.rs+++ b/crates/gpui/src/window.rs@@ -1961,7 +1961,7 @@ impl Window {}/// Determine whether the given action is available along the dispatch path to the currently focused element.- pub fn is_action_available(&self, action: &dyn Action, cx: &mut App) -> bool {+ pub fn is_action_available(&self, action: &dyn Action, cx: &App) -> bool {let node_id =self.focus_node_id_in_rendered_frame(self.focused(cx).map(|handle| handle.id));self.rendered_frame@@ -1969,6 +1969,14 @@ impl Window {.is_action_available(action, node_id)}+ /// Determine whether the given action is available along the dispatch path to the given focus_handle.+ pub fn is_action_available_in(&self, action: &dyn Action, focus_handle: &FocusHandle) -> bool {+ let node_id = self.focus_node_id_in_rendered_frame(Some(focus_handle.id));+ self.rendered_frame+ .dispatch_tree+ .is_action_available(action, node_id)+ }+/// The position of the mouse relative to the window.pub fn mouse_position(&self) -> Point<Pixels> {self.mouse_position