diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rs index 23aac6526f0168bd19cc5c46d030e167a59c9482..da69599e37035f00bba2da611eda4d2419d68328 100644 --- a/crates/gpui3/src/app.rs +++ b/crates/gpui3/src/app.rs @@ -167,6 +167,7 @@ impl AppContext { } Effect::Emit { .. } => self.pending_effects.push_back(effect), Effect::FocusChanged { .. } => self.pending_effects.push_back(effect), + Effect::Refresh => self.pending_effects.push_back(effect), } } @@ -181,6 +182,9 @@ impl AppContext { Effect::FocusChanged { window_id, focused } => { self.apply_focus_changed(window_id, focused) } + Effect::Refresh => { + self.apply_refresh(); + } } } else { break; @@ -286,6 +290,14 @@ impl AppContext { .ok(); } + pub fn apply_refresh(&mut self) { + for window in self.windows.values_mut() { + if let Some(window) = window.as_mut() { + window.dirty = true; + } + } + } + pub fn to_async(&self) -> AsyncAppContext { AsyncAppContext(unsafe { mem::transmute(self.this.clone()) }) } @@ -408,10 +420,7 @@ impl AppContext { pub fn bind_keys(&mut self, bindings: impl IntoIterator) { self.keymap.write().add_bindings(bindings); - let window_ids = self.windows.keys().collect::>(); - for window_id in window_ids { - self.update_window(window_id, |cx| cx.notify()).unwrap(); - } + self.push_effect(Effect::Refresh); } } @@ -502,6 +511,7 @@ pub(crate) enum Effect { window_id: WindowId, focused: Option, }, + Refresh, } #[cfg(test)]