Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Checkpoint

Antonio Scandurra7149f99f02bc
diff --git a/crates/gpui3/src/view.rs b/crates/gpui3/src/view.rs
index 8d4b72aa438..cc9d2d3d278 100644
--- a/crates/gpui3/src/view.rs
+++ b/crates/gpui3/src/view.rs
@@ -67,7 +67,11 @@ impl<V: 'static + Send + Sync> Element for View<V> {
_: Option<Self::ElementState>,
cx: &mut ViewContext<()>,
) -> Self::ElementState {
- self.state.update(cx, |state, cx| (self.render)(state, cx))
+ self.state.update(cx, |state, cx| {
+ let mut any_element = (self.render)(state, cx);
+ any_element.initialize(state, cx);
+ any_element
+ })
}
fn layout(
@@ -161,8 +165,11 @@ impl<V: Send + Sync + 'static> ViewObject for View<V> {
fn initialize(&mut self, cx: &mut WindowContext) -> AnyBox {
cx.with_element_id(self.entity_id(), |cx| {
- self.state
- .update(cx, |state, cx| Box::new((self.render)(state, cx)) as AnyBox)
+ self.state.update(cx, |state, cx| {
+ let mut any_element = Box::new((self.render)(state, cx));
+ any_element.initialize(state, cx);
+ any_element as AnyBox
+ })
})
}
diff --git a/crates/gpui3_macros/src/derive_element.rs b/crates/gpui3_macros/src/derive_element.rs
index bfe7a301c20..d7510faf99c 100644
--- a/crates/gpui3_macros/src/derive_element.rs
+++ b/crates/gpui3_macros/src/derive_element.rs
@@ -65,7 +65,9 @@ pub fn derive_element(input: TokenStream) -> TokenStream {
) -> Self::ElementState {
use gpui3::IntoAnyElement;
- self.render(view_state, cx).into_any()
+ let mut element = self.render(view_state, cx).into_any();
+ element.initialize(view_state, cx);
+ element
}
fn layout(