Use correct context path for focused element in WindowContext::bindings_for_action (#18843)
Previously, we were reaching in and using the context_stack on the dispatch tree, which was incorrect. /cc @as-cii /cc @ConradIrwin Release Notes: - N/A --------- Co-authored-by: Michael Sloan <michael@zed.dev>
This commit is contained in:
co-authored by
Michael Sloan
parent
7931342455
commit
e47b305ca7
@@ -68,7 +68,7 @@ pub(crate) struct DispatchNodeId(usize);
|
||||
|
||||
pub(crate) struct DispatchTree {
|
||||
node_stack: Vec<DispatchNodeId>,
|
||||
pub(crate) context_stack: Vec<KeyContext>,
|
||||
context_stack: Vec<KeyContext>,
|
||||
view_stack: Vec<EntityId>,
|
||||
nodes: Vec<DispatchNode>,
|
||||
focusable_node_ids: FxHashMap<FocusId, DispatchNodeId>,
|
||||
@@ -396,13 +396,13 @@ impl DispatchTree {
|
||||
pub fn bindings_for_action(
|
||||
&self,
|
||||
action: &dyn Action,
|
||||
context_stack: &[KeyContext],
|
||||
context_path: &[KeyContext],
|
||||
) -> Vec<KeyBinding> {
|
||||
let keymap = self.keymap.borrow();
|
||||
keymap
|
||||
.bindings_for_action(action)
|
||||
.filter(|binding| {
|
||||
let (bindings, _) = keymap.bindings_for_input(&binding.keystrokes, context_stack);
|
||||
let (bindings, _) = keymap.bindings_for_input(&binding.keystrokes, context_path);
|
||||
bindings
|
||||
.iter()
|
||||
.next()
|
||||
@@ -519,6 +519,13 @@ impl DispatchTree {
|
||||
dispatch_path
|
||||
}
|
||||
|
||||
pub fn context_path(&self, node_id: DispatchNodeId) -> SmallVec<[KeyContext; 32]> {
|
||||
self.dispatch_path(node_id)
|
||||
.into_iter()
|
||||
.filter_map(|node_id| self.node(node_id).context.clone())
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn focus_path(&self, focus_id: FocusId) -> SmallVec<[FocusId; 8]> {
|
||||
let mut focus_path: SmallVec<[FocusId; 8]> = SmallVec::new();
|
||||
let mut current_node_id = self.focusable_node_ids.get(&focus_id).copied();
|
||||
|
||||
Reference in New Issue
Block a user