Make Node::context
optional as well
This was an oversight in d09dfe0
.
Co-Authored-By: Marshall <marshall@zed.dev>
This commit is contained in:
parent
5e558e2a58
commit
2aee3e3192
2 changed files with 9 additions and 9 deletions
|
@ -28,7 +28,7 @@ pub(crate) struct DispatchTree {
|
||||||
pub(crate) struct DispatchNode {
|
pub(crate) struct DispatchNode {
|
||||||
pub key_listeners: SmallVec<[KeyListener; 2]>,
|
pub key_listeners: SmallVec<[KeyListener; 2]>,
|
||||||
pub action_listeners: SmallVec<[DispatchActionListener; 16]>,
|
pub action_listeners: SmallVec<[DispatchActionListener; 16]>,
|
||||||
pub context: KeyContext,
|
pub context: Option<KeyContext>,
|
||||||
parent: Option<DispatchNodeId>,
|
parent: Option<DispatchNodeId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ impl DispatchTree {
|
||||||
});
|
});
|
||||||
self.node_stack.push(node_id);
|
self.node_stack.push(node_id);
|
||||||
if let Some(context) = context {
|
if let Some(context) = context {
|
||||||
self.active_node().context = context.clone();
|
self.active_node().context = Some(context.clone());
|
||||||
self.context_stack.push(context);
|
self.context_stack.push(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pop_node(&mut self) {
|
pub fn pop_node(&mut self) {
|
||||||
let node_id = self.node_stack.pop().unwrap();
|
let node_id = self.node_stack.pop().unwrap();
|
||||||
if !self.nodes[node_id.0].context.is_empty() {
|
if self.nodes[node_id.0].context.is_some() {
|
||||||
self.context_stack.pop();
|
self.context_stack.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,8 +95,8 @@ impl DispatchTree {
|
||||||
self.context_stack.clear();
|
self.context_stack.clear();
|
||||||
for node_id in dispatch_path {
|
for node_id in dispatch_path {
|
||||||
let node = self.node(node_id);
|
let node = self.node(node_id);
|
||||||
if !node.context.is_empty() {
|
if let Some(context) = node.context.clone() {
|
||||||
self.context_stack.push(node.context.clone());
|
self.context_stack.push(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((context_stack, matcher)) = old_tree
|
if let Some((context_stack, matcher)) = old_tree
|
||||||
|
|
|
@ -1393,8 +1393,8 @@ impl<'a> WindowContext<'a> {
|
||||||
for node_id in &dispatch_path {
|
for node_id in &dispatch_path {
|
||||||
let node = self.window.current_frame.dispatch_tree.node(*node_id);
|
let node = self.window.current_frame.dispatch_tree.node(*node_id);
|
||||||
|
|
||||||
if !node.context.is_empty() {
|
if let Some(context) = node.context.clone() {
|
||||||
context_stack.push(node.context.clone());
|
context_stack.push(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
for key_listener in node.key_listeners.clone() {
|
for key_listener in node.key_listeners.clone() {
|
||||||
|
@ -1418,7 +1418,7 @@ impl<'a> WindowContext<'a> {
|
||||||
|
|
||||||
// Match keystrokes
|
// Match keystrokes
|
||||||
let node = self.window.current_frame.dispatch_tree.node(*node_id);
|
let node = self.window.current_frame.dispatch_tree.node(*node_id);
|
||||||
if !node.context.is_empty() {
|
if node.context.is_some() {
|
||||||
if let Some(key_down_event) = event.downcast_ref::<KeyDownEvent>() {
|
if let Some(key_down_event) = event.downcast_ref::<KeyDownEvent>() {
|
||||||
if let Some(found) = self
|
if let Some(found) = self
|
||||||
.window
|
.window
|
||||||
|
@ -1563,7 +1563,7 @@ impl<'a> WindowContext<'a> {
|
||||||
let context_stack = dispatch_tree
|
let context_stack = dispatch_tree
|
||||||
.dispatch_path(node_id)
|
.dispatch_path(node_id)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|node_id| dispatch_tree.node(node_id).context.clone())
|
.filter_map(|node_id| dispatch_tree.node(node_id).context.clone())
|
||||||
.collect();
|
.collect();
|
||||||
dispatch_tree.bindings_for_action(action, &context_stack)
|
dispatch_tree.bindings_for_action(action, &context_stack)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue