Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Checkpoint
Antonio Scandurraa69dbafe3c92
diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rsindex 20dc3d3f348..90c024f83d2 100644--- a/crates/gpui3/src/app.rs+++ b/crates/gpui3/src/app.rs@@ -88,8 +88,8 @@ impl App {}}-type Handler = Arc<dyn Fn(&mut AppContext) -> bool + Send + Sync + 'static>;-type EventHandler = Arc<dyn Fn(&dyn Any, &mut AppContext) -> bool + Send + Sync + 'static>;+type Handler = Box<dyn Fn(&mut AppContext) -> bool + Send + Sync + 'static>;+type EventHandler = Box<dyn Fn(&dyn Any, &mut AppContext) -> bool + Send + Sync + 'static>;type FrameCallback = Box<dyn FnOnce(&mut WindowContext) + Send>;pub struct AppContext {diff --git a/crates/gpui3/src/app/model_context.rs b/crates/gpui3/src/app/model_context.rsindex 0b30442feff..56e10e489bc 100644--- a/crates/gpui3/src/app/model_context.rs+++ b/crates/gpui3/src/app/model_context.rs@@ -2,7 +2,7 @@ use crate::{AppContext, Context, Effect, EntityId, EventEmitter, Handle, Reference, Subscription,WeakHandle,};-use std::{marker::PhantomData, sync::Arc};+use std::marker::PhantomData;pub struct ModelContext<'a, T> {app: Reference<'a, AppContext>,@@ -50,7 +50,7 @@ impl<'a, T: Send + Sync + 'static> ModelContext<'a, T> {let handle = handle.downgrade();self.app.observers.insert(handle.id,- Arc::new(move |cx| {+ Box::new(move |cx| {if let Some((this, handle)) = this.upgrade(cx).zip(handle.upgrade(cx)) {this.update(cx, |this, cx| on_notify(this, handle, cx));true@@ -73,7 +73,7 @@ impl<'a, T: Send + Sync + 'static> ModelContext<'a, T> {let handle = handle.downgrade();self.app.event_handlers.insert(handle.id,- Arc::new(move |event, cx| {+ Box::new(move |event, cx| {let event = event.downcast_ref().expect("invalid event type");if let Some((this, handle)) = this.upgrade(cx).zip(handle.upgrade(cx)) {this.update(cx, |this, cx| on_event(this, handle, event, cx));diff --git a/crates/gpui3/src/subscription.rs b/crates/gpui3/src/subscription.rsindex 4eaf9d9787c..509b29e4686 100644--- a/crates/gpui3/src/subscription.rs+++ b/crates/gpui3/src/subscription.rs@@ -3,11 +3,16 @@ use parking_lot::Mutex;use std::{fmt::Debug, mem, sync::Arc};use util::post_inc;-#[derive(Clone)]pub(crate) struct SubscriberSet<EmitterKey, Callback>(Arc<Mutex<SubscriberSetState<EmitterKey, Callback>>>,);+impl<EmitterKey, Callback> Clone for SubscriberSet<EmitterKey, Callback> {+ fn clone(&self) -> Self {+ SubscriberSet(self.0.clone())+ }+}+struct SubscriberSetState<EmitterKey, Callback> {subscribers: BTreeMap<EmitterKey, BTreeMap<usize, Callback>>,dropped_subscribers: BTreeSet<(EmitterKey, usize)>,diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rsindex 1c0ded433e5..02dbe7c629b 100644--- a/crates/gpui3/src/window.rs+++ b/crates/gpui3/src/window.rs@@ -909,7 +909,7 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> {let window_handle = self.window.handle;self.app.observers.insert(handle.id,- Arc::new(move |cx| {+ Box::new(move |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))@@ -936,7 +936,7 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> {let window_handle = self.window.handle;self.app.event_handlers.insert(handle.id,- Arc::new(move |event, cx| {+ Box::new(move |event, cx| {cx.update_window(window_handle.id, |cx| {if let Some(handle) = handle.upgrade(cx) {let event = event.downcast_ref().expect("invalid event type");