diff --git a/crates/gpui2/src/app.rs b/crates/gpui2/src/app.rs index 9b9a5921e17dca7fa3c22571ca6f6f0fdc9e5c55..deb03498bc7d1783aac36acdd8bb88428d7c5c64 100644 --- a/crates/gpui2/src/app.rs +++ b/crates/gpui2/src/app.rs @@ -571,6 +571,7 @@ impl AppContext { loop { self.release_dropped_entities(); self.release_dropped_focus_handles(); + if let Some(effect) = self.pending_effects.pop_front() { match effect { Effect::Notify { emitter } => { @@ -610,7 +611,8 @@ impl AppContext { .values() .filter_map(|window| { let window = window.as_ref()?; - window.dirty.then_some(window.handle) + dbg!(window.focus_invalidated); + (window.dirty || window.focus_invalidated).then_some(window.handle) }) .collect::>() { diff --git a/crates/gpui2/src/window.rs b/crates/gpui2/src/window.rs index d2f48917112f5eda16c8a9a8a684bf47b036da09..895ae788627aa7d608762cef2ca0c4b6b4bbd15e 100644 --- a/crates/gpui2/src/window.rs +++ b/crates/gpui2/src/window.rs @@ -243,6 +243,9 @@ pub struct Window { pub(crate) dirty: bool, activation_observers: SubscriberSet<(), AnyObserver>, pub(crate) focus: Option, + + #[cfg(any(test, feature = "test-support"))] + pub(crate) focus_invalidated: bool, } pub(crate) struct ElementStateBox { @@ -381,6 +384,9 @@ impl Window { dirty: false, activation_observers: SubscriberSet::new(), focus: None, + + #[cfg(any(test, feature = "test-support"))] + focus_invalidated: false, } } } @@ -461,6 +467,12 @@ impl<'a> WindowContext<'a> { .rendered_frame .dispatch_tree .clear_pending_keystrokes(); + + #[cfg(any(test, feature = "test-support"))] + { + self.window.focus_invalidated = true; + } + self.notify(); } @@ -1274,13 +1286,15 @@ impl<'a> WindowContext<'a> { self.window.root_view = Some(root_view); let previous_focus_path = self.window.rendered_frame.focus_path(); - - let window = &mut self.window; - mem::swap(&mut window.rendered_frame, &mut window.next_frame); - + mem::swap(&mut self.window.rendered_frame, &mut self.window.next_frame); let current_focus_path = self.window.rendered_frame.focus_path(); if previous_focus_path != current_focus_path { + #[cfg(any(test, feature = "test-support"))] + { + self.window.focus_invalidated = false; + } + if !previous_focus_path.is_empty() && current_focus_path.is_empty() { self.window .blur_listeners diff --git a/crates/project_panel2/src/project_panel.rs b/crates/project_panel2/src/project_panel.rs index adcd21cac6d35f2a00f24938184122d7c7d842c1..5e71266c2177c857d6d5fbd6f34c1d3f59ef68da 100644 --- a/crates/project_panel2/src/project_panel.rs +++ b/crates/project_panel2/src/project_panel.rs @@ -739,6 +739,7 @@ impl ProjectPanel { }); self.filename_editor.update(cx, |editor, cx| { editor.clear(cx); + println!("focusing"); editor.focus(cx); }); self.update_visible_entries(Some((worktree_id, NEW_ENTRY_ID)), cx);