Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Antonio Scandurra15567493bafa
diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rsindex 28bc0b636e8..5752d91261b 100644--- a/crates/gpui3/src/app.rs+++ b/crates/gpui3/src/app.rs@@ -115,12 +115,12 @@ impl AppContext {pub(crate) fn update_window<R>(&mut self,- handle: AnyWindowHandle,+ id: WindowId,update: impl FnOnce(&mut WindowContext) -> R,) -> Result<R> {let mut window = self.windows- .get_mut(handle.id)+ .get_mut(id).ok_or_else(|| anyhow!("window not found"))?.take().unwrap();@@ -129,7 +129,7 @@ impl AppContext {window.dirty = true;self.windows- .get_mut(handle.id)+ .get_mut(id).ok_or_else(|| anyhow!("window not found"))?.replace(window);@@ -152,6 +152,23 @@ impl AppContext {Effect::Notify(entity_id) => self.apply_notify_effect(entity_id),}}++ let dirty_window_ids = self+ .windows+ .iter()+ .filter_map(|(window_id, window)| {+ let window = window.as_ref().unwrap();+ if window.dirty {+ Some(window_id)+ } else {+ None+ }+ })+ .collect::<Vec<_>>();++ for dirty_window_id in dirty_window_ids {+ self.update_window(dirty_window_id, |cx| cx.draw());+ }}fn apply_notify_effect(&mut self, updated_entity: EntityId) {diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rsindex b1e1407aa60..ca28928739d 100644--- a/crates/gpui3/src/window.rs+++ b/crates/gpui3/src/window.rs@@ -133,7 +133,7 @@ impl<'a, 'w> WindowContext<'a, 'w> {if window_handle == self.window.handle {Ok(update(self))} else {- self.app.update_window(window_handle, update)+ self.app.update_window(window_handle.id, update)}}}@@ -258,7 +258,7 @@ impl<'a, 'w, T: Send + Sync + 'static> ViewContext<'a, 'w, T> {.entry(handle.id).or_default().push(Arc::new(move |cx| {- cx.update_window(window_handle, |cx| {+ cx.update_window(window_handle.id, |cx| {if let Some(handle) = handle.upgrade(cx) {this.update(cx, |this, cx| on_notify(this, handle, cx)).is_ok()