@@ -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()
}
}),
@@ -63,6 +63,16 @@ impl<V: 'static> View<V> {
pub fn read<'a>(&self, cx: &'a AppContext) -> &'a V {
self.model.read(cx)
}
+
+ pub fn render_with<C>(&self, component: C) -> RenderViewWith<C, V>
+ where
+ C: 'static + Component<V>,
+ {
+ RenderViewWith {
+ view: self.clone(),
+ component: Some(component),
+ }
+ }
}
impl<V> Clone for View<V> {
@@ -281,12 +291,12 @@ where
}
}
-pub struct RenderView<C, V> {
+pub struct RenderViewWith<C, V> {
view: View<V>,
component: Option<C>,
}
-impl<C, ParentViewState, ViewState> Component<ParentViewState> for RenderView<C, ViewState>
+impl<C, ParentViewState, ViewState> Component<ParentViewState> for RenderViewWith<C, ViewState>
where
C: 'static + Component<ViewState>,
ParentViewState: 'static,
@@ -297,7 +307,7 @@ where
}
}
-impl<C, ParentViewState, ViewState> Element<ParentViewState> for RenderView<C, ViewState>
+impl<C, ParentViewState, ViewState> Element<ParentViewState> for RenderViewWith<C, ViewState>
where
C: 'static + Component<ViewState>,
ParentViewState: 'static,
@@ -348,17 +358,6 @@ where
}
}
-pub fn render_view<C, V>(view: &View<V>, component: C) -> RenderView<C, V>
-where
- C: 'static + Component<V>,
- V: 'static,
-{
- RenderView {
- view: view.clone(),
- component: Some(component),
- }
-}
-
mod any_view {
use crate::{AnyElement, AnyView, BorrowWindow, LayoutId, Render, WindowContext};
use std::any::Any;