Clear the state of keystroke matchers when focus changes
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
3978d4e872
commit
1d04dc5dbf
2 changed files with 45 additions and 8 deletions
|
@ -393,6 +393,10 @@ impl<'a> WindowContext<'a> {
|
|||
|
||||
/// Move focus to the element associated with the given `FocusHandle`.
|
||||
pub fn focus(&mut self, handle: &FocusHandle) {
|
||||
if self.window.focus == Some(handle.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
let focus_id = handle.id;
|
||||
|
||||
if self.window.last_blur.is_none() {
|
||||
|
@ -400,6 +404,10 @@ impl<'a> WindowContext<'a> {
|
|||
}
|
||||
|
||||
self.window.focus = Some(focus_id);
|
||||
self.window
|
||||
.current_frame
|
||||
.dispatch_tree
|
||||
.clear_keystroke_matchers();
|
||||
self.app.push_effect(Effect::FocusChanged {
|
||||
window_handle: self.window.handle,
|
||||
focused: Some(focus_id),
|
||||
|
@ -1091,6 +1099,14 @@ impl<'a> WindowContext<'a> {
|
|||
});
|
||||
}
|
||||
|
||||
self.window
|
||||
.current_frame
|
||||
.dispatch_tree
|
||||
.preserve_keystroke_matchers(
|
||||
&mut self.window.previous_frame.dispatch_tree,
|
||||
self.window.focus,
|
||||
);
|
||||
|
||||
self.window.root_view = Some(root_view);
|
||||
let scene = self.window.current_frame.scene_builder.build();
|
||||
|
||||
|
@ -2093,7 +2109,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||
window
|
||||
.current_frame
|
||||
.dispatch_tree
|
||||
.push_node(context.clone(), &mut window.previous_frame.dispatch_tree);
|
||||
.push_node(context.clone());
|
||||
if let Some(focus_handle) = focus_handle.as_ref() {
|
||||
window
|
||||
.current_frame
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue