diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs index 41757b4dc2..af7da8e837 100644 --- a/crates/editor2/src/editor.rs +++ b/crates/editor2/src/editor.rs @@ -39,12 +39,12 @@ use futures::FutureExt; use fuzzy::{StringMatch, StringMatchCandidate}; use git::diff_hunk_to_display; use gpui::{ - action, actions, div, point, prelude::*, px, relative, rems, render_view, size, uniform_list, - AnyElement, AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, - Component, Context, EventEmitter, FocusHandle, FontFeatures, FontStyle, FontWeight, - HighlightStyle, Hsla, InputHandler, KeyContext, Model, MouseButton, ParentComponent, Pixels, - Render, Styled, Subscription, Task, TextStyle, UniformListScrollHandle, View, ViewContext, - VisualContext, WeakView, WindowContext, + action, actions, div, point, prelude::*, px, relative, rems, size, uniform_list, AnyElement, + AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Component, Context, + EventEmitter, FocusHandle, FontFeatures, FontStyle, FontWeight, HighlightStyle, Hsla, + InputHandler, KeyContext, Model, MouseButton, ParentComponent, Pixels, Render, Styled, + Subscription, Task, TextStyle, UniformListScrollHandle, View, ViewContext, VisualContext, + WeakView, WindowContext, }; use highlight_matching_bracket::refresh_matching_bracket_highlights; use hover_popover::{hide_hover, HoverState}; @@ -7777,25 +7777,18 @@ impl Editor { } div() .pl(cx.anchor_x) - .child(render_view( + .child(rename_editor.render_with(EditorElement::new( &rename_editor, - EditorElement::new( - &rename_editor, - EditorStyle { - background: cx.theme().system().transparent, - local_player: cx.editor_style.local_player, - text: text_style, - scrollbar_width: cx - .editor_style - .scrollbar_width, - syntax: cx.editor_style.syntax.clone(), - diagnostic_style: cx - .editor_style - .diagnostic_style - .clone(), - }, - ), - )) + EditorStyle { + background: cx.theme().system().transparent, + local_player: cx.editor_style.local_player, + text: text_style, + scrollbar_width: cx.editor_style.scrollbar_width, + syntax: cx.editor_style.syntax.clone(), + diagnostic_style: + cx.editor_style.diagnostic_style.clone(), + }, + ))) .render() } }), diff --git a/crates/gpui2/src/view.rs b/crates/gpui2/src/view.rs index c0bbe00db6..5a2cc0f103 100644 --- a/crates/gpui2/src/view.rs +++ b/crates/gpui2/src/view.rs @@ -63,6 +63,16 @@ impl View { pub fn read<'a>(&self, cx: &'a AppContext) -> &'a V { self.model.read(cx) } + + pub fn render_with(&self, component: C) -> RenderViewWith + where + C: 'static + Component, + { + RenderViewWith { + view: self.clone(), + component: Some(component), + } + } } impl Clone for View { @@ -281,12 +291,12 @@ where } } -pub struct RenderView { +pub struct RenderViewWith { view: View, component: Option, } -impl Component for RenderView +impl Component for RenderViewWith where C: 'static + Component, ParentViewState: 'static, @@ -297,7 +307,7 @@ where } } -impl Element for RenderView +impl Element for RenderViewWith where C: 'static + Component, ParentViewState: 'static, @@ -348,17 +358,6 @@ where } } -pub fn render_view(view: &View, component: C) -> RenderView -where - C: 'static + Component, - V: 'static, -{ - RenderView { - view: view.clone(), - component: Some(component), - } -} - mod any_view { use crate::{AnyElement, AnyView, BorrowWindow, LayoutId, Render, WindowContext}; use std::any::Any;