Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
fix gpui2
Mikayla6985b708592b
diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rsindex 0590372694d..630b368b951 100644--- a/crates/gpui2/src/elements/div.rs+++ b/crates/gpui2/src/elements/div.rs@@ -266,7 +266,7 @@ pub trait InteractiveElement: Sized + Element {.key_down_listeners.push(Box::new(move |event, phase, cx| {if phase == DispatchPhase::Capture {- (listener.callback)(event, cx)+ listener(event, cx)}}));self@@ -277,7 +277,7 @@ pub trait InteractiveElement: Sized + Element {.key_up_listeners.push(Box::new(move |event, phase, cx| {if phase == DispatchPhase::Bubble {- (listener.callback)(event, cx)+ listener(event, cx)}}));self@@ -291,7 +291,7 @@ pub trait InteractiveElement: Sized + Element {.key_up_listeners.push(Box::new(move |event, phase, cx| {if phase == DispatchPhase::Capture {- (listener.callback)(event, cx)+ listener(event, cx)}}));self@@ -326,7 +326,7 @@ pub trait InteractiveElement: Sized + Element {self.interactivity().drop_listeners.push((TypeId::of::<W>(),Box::new(move |dragged_view, cx| {- (listener.callback)(&dragged_view.downcast().unwrap(), cx);+ listener(&dragged_view.downcast().unwrap(), cx);}),));self@@ -384,7 +384,7 @@ pub trait StatefulInteractiveElement: InteractiveElement {{self.interactivity().click_listeners- .push(Box::new(move |event, cx| (listener.callback)(event, cx)));+ .push(Box::new(move |event, cx| listener(event, cx)));self}@@ -398,7 +398,7 @@ pub trait StatefulInteractiveElement: InteractiveElement {"calling on_drag more than once on the same element is not supported");self.interactivity().drag_listener = Some(Box::new(move |cursor_offset, cx| AnyDrag {- view: (listener.callback)(cx).into(),+ view: listener(cx).into(),cursor_offset,}));self@@ -424,8 +424,7 @@ pub trait StatefulInteractiveElement: InteractiveElement {self.interactivity().tooltip_builder.is_none(),"calling tooltip more than once on the same element is not supported");- self.interactivity().tooltip_builder =- Some(Rc::new(move |cx| (build_tooltip.callback)(cx)));+ self.interactivity().tooltip_builder = Some(Rc::new(build_tooltip));self}@@ -456,7 +455,7 @@ pub trait FocusableElement: InteractiveElement {.focus_listeners.push(Box::new(move |focus_handle, event, cx| {if event.focused.as_ref() == Some(focus_handle) {- (listener.callback)(event, cx)+ listener(event, cx)}}));self@@ -470,7 +469,7 @@ pub trait FocusableElement: InteractiveElement {.focus_listeners.push(Box::new(move |focus_handle, event, cx| {if event.blurred.as_ref() == Some(focus_handle) {- (listener.callback)(event, cx)+ listener(event, cx)}}));self@@ -493,7 +492,7 @@ pub trait FocusableElement: InteractiveElement {.map_or(false, |focused| focus_handle.contains(focused, cx));if !descendant_blurred && descendant_focused {- (listener.callback)(event, cx)+ listener(event, cx)}}));self@@ -515,7 +514,7 @@ pub trait FocusableElement: InteractiveElement {.as_ref().map_or(false, |focused| focus_handle.contains(focused, cx));if descendant_blurred && !descendant_focused {- (listener.callback)(event, cx)+ listener(event, cx)}}));self@@ -907,7 +906,7 @@ impl Interactivity {*was_hovered = is_hovered;drop(was_hovered);- (hover_listener.callback)(&is_hovered, cx);+ hover_listener(&is_hovered, cx);}});}diff --git a/crates/gpui2/src/interactive.rs b/crates/gpui2/src/interactive.rsindex be5ebf7cff8..3dfe0c3b436 100644--- a/crates/gpui2/src/interactive.rs+++ b/crates/gpui2/src/interactive.rs@@ -307,7 +307,7 @@ mod test {.key_context("parent").on_key_down(cx.listener(|this, _, _| this.saw_key_down = true)).on_action(- cx.callback(|this: &mut TestView, _: &TestAction, _| {+ cx.listener(|this: &mut TestView, _: &TestAction, _| {this.saw_action = true}),)diff --git a/crates/gpui2_macros/src/derive_render_once.rs b/crates/gpui2_macros/src/derive_render_once.rsindex 732f2df21f1..efe6aab0bb9 100644--- a/crates/gpui2_macros/src/derive_render_once.rs+++ b/crates/gpui2_macros/src/derive_render_once.rs@@ -1,37 +1,17 @@use proc_macro::TokenStream;use quote::quote;-use syn::{parse_macro_input, parse_quote, DeriveInput};+use syn::{parse_macro_input, DeriveInput};pub fn derive_render_once(input: TokenStream) -> TokenStream {let ast = parse_macro_input!(input as DeriveInput);let type_name = &ast.ident;-- let mut trait_generics = ast.generics.clone();- let view_type = if let Some(view_type) = specified_view_type(&ast) {- quote! { #view_type }- } else {- if let Some(first_type_param) = ast.generics.params.iter().find_map(|param| {- if let syn::GenericParam::Type(type_param) = param {- Some(type_param.ident.clone())- } else {- None- }- }) {- quote! { #first_type_param }- } else {- trait_generics.params.push(parse_quote! { V: 'static });- quote! { V }- }- };-- let (impl_generics, _, where_clause) = trait_generics.split_for_impl();- let (_, type_generics, _) = ast.generics.split_for_impl();+ let (impl_generics, type_generics, where_clause) = ast.generics.split_for_impl();let gen = quote! {- impl #impl_generics gpui::RenderOnce<#view_type> for #type_name #type_generics+ impl #impl_generics gpui::RenderOnce for #type_name #type_generics#where_clause{- type Element = gpui::CompositeElement<#view_type, Self>;+ type Element = gpui::CompositeElement<Self>;fn element_id(&self) -> Option<ElementId> {None@@ -45,20 +25,3 @@ pub fn derive_render_once(input: TokenStream) -> TokenStream {gen.into()}--fn specified_view_type(ast: &DeriveInput) -> Option<proc_macro2::Ident> {- ast.attrs.iter().find_map(|attr| {- if attr.path.is_ident("view") {- if let Ok(syn::Meta::NameValue(meta_name_value)) = attr.parse_meta() {- if let syn::Lit::Str(lit_str) = meta_name_value.lit {- return Some(- lit_str- .parse::<syn::Ident>()- .expect("Failed to parse view_type"),- );- }- }- }- None- })-}