Clear pending keystrokes when an action is dispatched (#3750)
Nathan Sobo
created
This prevents the `cmd-k` keystroke, which clears the terminal, from
staying around as a pending keystroke on the parent workspace.
Release Notes:
- N/A
@@ -572,6 +572,17 @@ impl<'a> WindowContext<'a> {
});
}
+ pub(crate) fn clear_pending_keystrokes(&mut self) {
+ self.window
+ .rendered_frame
+ .dispatch_tree
+ .clear_pending_keystrokes();
+ self.window
+ .next_frame
+ .dispatch_tree
+ .clear_pending_keystrokes();
+ }
+
/// Schedules the given function to be run at the end of the current effect cycle, allowing entities
/// that are currently on the stack to be returned to the app.
pub fn defer(&mut self, f: impl FnOnce(&mut WindowContext) + 'static) {
@@ -1626,6 +1637,10 @@ impl<'a> WindowContext<'a> {
}
}
+ if !actions.is_empty() {
+ self.clear_pending_keystrokes();
+ }
+
for action in actions {
self.dispatch_action_on_node(node_id, action.boxed_clone());
if !self.propagate_event {