Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Checkpoint
Antonio Scandurra80c0a6ead36a
diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rsindex 17676ca645d..4f0670fa9a9 100644--- a/crates/gpui3/src/app.rs+++ b/crates/gpui3/src/app.rs@@ -148,8 +148,8 @@ impl AppContext {fn flush_effects(&mut self) {while let Some(effect) = self.pending_effects.pop_front() {match effect {- Effect::Notify(entity_id) => self.apply_notify_effect(entity_id),- Effect::Emit { entity_id, event } => self.apply_emit_effect(entity_id, event),+ Effect::Notify { emitter } => self.apply_notify_effect(emitter),+ Effect::Emit { emitter, event } => self.apply_emit_effect(emitter, event),}}@@ -171,16 +171,16 @@ impl AppContext {}}- fn apply_notify_effect(&mut self, updated_entity: EntityId) {+ fn apply_notify_effect(&mut self, emitter: EntityId) {self.observers.clone()- .retain(&updated_entity, |handler| handler(self));+ .retain(&emitter, |handler| handler(self));}- fn apply_emit_effect(&mut self, updated_entity: EntityId, event: Box<dyn Any>) {+ fn apply_emit_effect(&mut self, emitter: EntityId, event: Box<dyn Any>) {self.event_handlers.clone()- .retain(&updated_entity, |handler| handler(&event, self));+ .retain(&emitter, |handler| handler(&event, self));}pub fn to_async(&self) -> AsyncAppContext {@@ -380,9 +380,11 @@ impl MainThread<AppContext> {}pub(crate) enum Effect {- Notify(EntityId),+ Notify {+ emitter: EntityId,+ },Emit {- entity_id: EntityId,+ emitter: EntityId,event: Box<dyn Any + Send + Sync + 'static>,},}diff --git a/crates/gpui3/src/app/model_context.rs b/crates/gpui3/src/app/model_context.rsindex 56e10e489bc..d646bd46110 100644--- a/crates/gpui3/src/app/model_context.rs+++ b/crates/gpui3/src/app/model_context.rs@@ -86,16 +86,16 @@ impl<'a, T: Send + Sync + 'static> ModelContext<'a, T> {}pub fn notify(&mut self) {- self.app- .pending_effects- .push_back(Effect::Notify(self.entity_id));+ self.app.pending_effects.push_back(Effect::Notify {+ emitter: self.entity_id,+ });}}impl<'a, T: EventEmitter + Send + Sync + 'static> ModelContext<'a, T> {pub fn emit(&mut self, event: T::Event) {self.app.pending_effects.push_back(Effect::Emit {- entity_id: self.entity_id,+ emitter: self.entity_id,event: Box::new(event),});}diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rsindex 1f1f87afac3..fefa617a0b1 100644--- a/crates/gpui3/src/window.rs+++ b/crates/gpui3/src/window.rs@@ -966,7 +966,9 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> {self.window_cx.app.pending_effects- .push_back(Effect::Notify(self.entity_id));+ .push_back(Effect::Notify {+ emitter: self.entity_id,+ });}pub fn run_on_main<R>(@@ -1016,9 +1018,8 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> {impl<'a, 'w, S: EventEmitter + Send + Sync + 'static> ViewContext<'a, 'w, S> {pub fn emit(&mut self, event: S::Event) {- let entity_id = self.entity_id;- self.app.pending_effects.push_back(Effect::Emit {- entity_id,+ self.window_cx.app.pending_effects.push_back(Effect::Emit {+ emitter: self.entity_id,event: Box::new(event),});}diff --git a/crates/storybook2/src/collab_panel.rs b/crates/storybook2/src/collab_panel.rsindex 9d529f4a478..2f733c1b760 100644--- a/crates/storybook2/src/collab_panel.rs+++ b/crates/storybook2/src/collab_panel.rs@@ -1,8 +1,7 @@use crate::theme::{theme, Theme};use gpui3::{- div, img, svg, view, AppContext, Context, Element, ElementId, IdentifiedElement,- IntoAnyElement, ParentElement, ScrollState, SharedString, StyleHelpers, Styled, View,- ViewContext, WindowContext,+ div, svg, view, AppContext, Context, Element, ElementId, IntoAnyElement, ParentElement,+ ScrollState, SharedString, StyleHelpers, Styled, View, ViewContext, WindowContext,};pub struct CollabPanel {diff --git a/crates/storybook2/src/storybook2.rs b/crates/storybook2/src/storybook2.rsindex 1c819328fa8..719ce348ea7 100644--- a/crates/storybook2/src/storybook2.rs+++ b/crates/storybook2/src/storybook2.rs@@ -1,13 +1,10 @@#![allow(dead_code, unused_variables)]use assets::Assets;-use gpui3::{- div, px, size, Bounds, Element, StyleHelpers, WindowBounds, WindowContext, WindowOptions,-};+use gpui3::{px, size, Bounds, WindowBounds, WindowOptions};use log::LevelFilter;use simplelog::SimpleLogger;use std::sync::Arc;-use themes::rose_pine;use workspace::workspace;mod assets;diff --git a/crates/storybook2/src/workspace.rs b/crates/storybook2/src/workspace.rsindex c2b8eab7592..e902df65653 100644--- a/crates/storybook2/src/workspace.rs+++ b/crates/storybook2/src/workspace.rs@@ -1,7 +1,7 @@use crate::{collab_panel::{collab_panel, CollabPanel},theme::{theme, themed},- themes::{rose_pine, rose_pine_dawn},+ themes::rose_pine,};use gpui3::{div, img, svg, view, Context, Element, ParentElement, RootView, StyleHelpers, Styled, View,