Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Nathan Sobo0673606de867
diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rsindex 214c46551f4..b241b76184d 100644--- a/crates/editor2/src/editor.rs+++ b/crates/editor2/src/editor.rs@@ -9376,7 +9376,7 @@ impl FocusableView for Editor {}}-impl Render for Editor {+impl Render<Self> for Editor {type Element = EditorElement;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {diff --git a/crates/editor2/src/element.rs b/crates/editor2/src/element.rsindex 0ee710da475..3140008bc3a 100644--- a/crates/editor2/src/element.rs+++ b/crates/editor2/src/element.rs@@ -21,7 +21,7 @@ use gpui::{div, point, px, relative, size, transparent_black, Action, AnyElement, AvailableSpace,BorrowWindow, Bounds, Component, ContentMask, Corners, DispatchPhase, Edges, Element,ElementId, ElementInputHandler, Entity, EntityId, Hsla, InteractiveElement, LineLayout,- MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels,+ MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, RenderOnce,ScrollWheelEvent, ShapedLine, SharedString, Size, StatefulInteractiveElement, Style, Styled,TextRun, TextStyle, View, ViewContext, WindowContext, WrappedLine,};@@ -2466,9 +2466,11 @@ impl Element<Editor> for EditorElement {}}-impl Component<Editor> for EditorElement {- fn render(self) -> AnyElement<Editor> {- AnyElement::new(self)+impl RenderOnce<Editor> for EditorElement {+ type Element = Self;++ fn render_once(self) -> Self::Element {+ self}}diff --git a/crates/storybook3/src/storybook3.rs b/crates/storybook3/src/storybook3.rsindex 291f8ce2ac4..e8f1827e01c 100644--- a/crates/storybook3/src/storybook3.rs+++ b/crates/storybook3/src/storybook3.rs@@ -59,7 +59,7 @@ struct TestView {story: AnyView,}-impl Render for TestView {+impl Render<Self> for TestView {type Element = Div<Self>;fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {diff --git a/crates/workspace2/src/dock.rs b/crates/workspace2/src/dock.rsindex 406a7a33d15..d6b8d9ae793 100644--- a/crates/workspace2/src/dock.rs+++ b/crates/workspace2/src/dock.rs@@ -1,8 +1,8 @@use crate::{status_bar::StatusItemView, Axis, Workspace};use gpui::{div, px, Action, AnchorCorner, AnyView, AppContext, Component, Div, Entity, EntityId,- EventEmitter, FocusHandle, FocusableView, ParentElement, Render, SharedString, Styled,- Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,+ EventEmitter, FocusHandle, FocusableView, ParentElement, Render, RenderOnce, SharedString,+ Styled, Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,};use schemars::JsonSchema;use serde::{Deserialize, Serialize};@@ -426,7 +426,7 @@ impl Dock {}}-impl Render for Dock {+impl Render<Self> for Dock {type Element = Div<Self>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {@@ -612,7 +612,7 @@ impl PanelButtons {// }// here be kittens-impl Render for PanelButtons {+impl Render<Self> for PanelButtons {type Element = Div<Self>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {@@ -706,7 +706,7 @@ pub mod test {}}- impl Render for TestPanel {+ impl Render<Self> for TestPanel {type Element = Div<Self>;fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {diff --git a/crates/workspace2/src/modal_layer.rs b/crates/workspace2/src/modal_layer.rsindex 8afd8317f94..3cbd8458f40 100644--- a/crates/workspace2/src/modal_layer.rs+++ b/crates/workspace2/src/modal_layer.rs@@ -71,7 +71,7 @@ impl ModalLayer {}}-impl Render for ModalLayer {+impl Render<Self> for ModalLayer {type Element = Div<Self>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {diff --git a/crates/workspace2/src/notifications.rs b/crates/workspace2/src/notifications.rsindex 7277cc6fc47..bb00973d5c5 100644--- a/crates/workspace2/src/notifications.rs+++ b/crates/workspace2/src/notifications.rs@@ -13,7 +13,7 @@ pub enum NotificationEvent {Dismiss,}-pub trait Notification: EventEmitter<NotificationEvent> + Render {}+pub trait Notification: EventEmitter<NotificationEvent> + Render<Self> {}pub trait NotificationHandle: Send {fn id(&self) -> EntityId;@@ -251,7 +251,7 @@ pub mod simple_message_notification {// }}- impl Render for MessageNotification {+ impl Render<Self> for MessageNotification {type Element = Div<Self>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rsindex d44d3471146..4ab78d8bca6 100644--- a/crates/workspace2/src/pane.rs+++ b/crates/workspace2/src/pane.rs@@ -593,7 +593,7 @@ impl Pane {self.items.iter()}- pub fn items_of_type<T: Render>(&self) -> impl '_ + Iterator<Item = View<T>> {+ pub fn items_of_type<T: Render<T>>(&self) -> impl '_ + Iterator<Item = View<T>> {self.items.iter().filter_map(|item| item.to_any().downcast().ok())@@ -1343,7 +1343,7 @@ impl Pane {item: &Box<dyn ItemHandle>,detail: usize,cx: &mut ViewContext<'_, Pane>,- ) -> impl Component<Self> {+ ) -> impl RenderOnce<Self> {let label = item.tab_content(Some(detail), cx);let close_icon = || {let id = item.item_id();@@ -1436,7 +1436,7 @@ impl Pane {)}- fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl Component<Self> {+ fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl RenderOnce<Self> {div().group("tab_bar").id("tab_bar")@@ -1895,7 +1895,7 @@ impl FocusableView for Pane {}}-impl Render for Pane {+impl Render<Self> for Pane {type Element = Focusable<Self, Div<Self>>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {@@ -2949,7 +2949,7 @@ struct DraggedTab {title: String,}-impl Render for DraggedTab {+impl Render<Self> for DraggedTab {type Element = Div<Self>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {diff --git a/crates/workspace2/src/pane_group.rs b/crates/workspace2/src/pane_group.rsindex d46757ff9f6..68f26295dc7 100644--- a/crates/workspace2/src/pane_group.rs+++ b/crates/workspace2/src/pane_group.rs@@ -6,7 +6,10 @@ use db2::sqlez::{bindable::{Bind, Column, StaticColumnCount},statement::Statement,};-use gpui::{point, size, AnyElement, AnyWeakView, Bounds, Model, Pixels, Point, View, ViewContext};+use gpui::{+ point, size, AnyElement, AnyWeakView, Bounds, Div, Model, Pixels, Point, RenderOnce, View,+ ViewContext,+};use parking_lot::Mutex;use project2::Project;use serde::Deserialize;@@ -130,7 +133,7 @@ impl PaneGroup {zoomed: Option<&AnyWeakView>,app_state: &Arc<AppState>,cx: &mut ViewContext<Workspace>,- ) -> impl Component<Workspace> {+ ) -> impl RenderOnce<Workspace> {self.root.render(project,0,@@ -202,7 +205,7 @@ impl Member {zoomed: Option<&AnyWeakView>,app_state: &Arc<AppState>,cx: &mut ViewContext<Workspace>,- ) -> impl Component<Workspace> {+ ) -> impl RenderOnce<Workspace> {match self {Member::Pane(pane) => {// todo!()@@ -212,7 +215,7 @@ impl Member {// Some(pane)// };- div().size_full().child(pane.clone()).render()+ div().size_full().child(pane.clone())// Stack::new()// .with_child(pane_element.contained().with_border(leader_border))@@ -559,7 +562,7 @@ impl PaneAxis {zoomed: Option<&AnyWeakView>,app_state: &Arc<AppState>,cx: &mut ViewContext<Workspace>,- ) -> AnyElement<Workspace> {+ ) -> Div<Workspace> {debug_assert!(self.members.len() == self.flexes.lock().len());div()@@ -582,11 +585,10 @@ impl PaneAxis {app_state,cx,)- .render(),- Member::Pane(pane) => pane.clone().render(),+ .render_into_any(),+ Member::Pane(pane) => pane.clone().render_into_any(),}}))- .render()// let mut pane_axis = PaneAxisElement::new(// self.axis,diff --git a/crates/workspace2/src/status_bar.rs b/crates/workspace2/src/status_bar.rsindex b0f905f8454..f961cac8f0f 100644--- a/crates/workspace2/src/status_bar.rs+++ b/crates/workspace2/src/status_bar.rs@@ -2,14 +2,14 @@ use std::any::TypeId;use crate::{ItemHandle, Pane};use gpui::{- div, AnyView, Component, Div, ParentElement, Render, Styled, Subscription, View,+ div, AnyView, Component, Div, ParentElement, Render, RenderOnce, Styled, Subscription, View,ViewContext, WindowContext,};use theme2::ActiveTheme;use ui::h_stack;use util::ResultExt;-pub trait StatusItemView: Render {+pub trait StatusItemView: Render<Self> {fn set_active_pane_item(&mut self,active_pane_item: Option<&dyn crate::ItemHandle>,@@ -34,7 +34,7 @@ pub struct StatusBar {_observe_active_pane: Subscription,}-impl Render for StatusBar {+impl Render<Self> for StatusBar {type Element = Div<Self>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {@@ -53,14 +53,14 @@ impl Render for StatusBar {}impl StatusBar {- fn render_left_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {+ fn render_left_tools(&self, cx: &mut ViewContext<Self>) -> impl RenderOnce<Self> {h_stack().items_center().gap_1().children(self.left_items.iter().map(|item| item.to_any()))}- fn render_right_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {+ fn render_right_tools(&self, cx: &mut ViewContext<Self>) -> impl RenderOnce<Self> {h_stack().items_center().gap_2()diff --git a/crates/workspace2/src/toolbar.rs b/crates/workspace2/src/toolbar.rsindex 1d67da06b22..072c67fda85 100644--- a/crates/workspace2/src/toolbar.rs+++ b/crates/workspace2/src/toolbar.rs@@ -7,7 +7,7 @@ pub enum ToolbarItemEvent {ChangeLocation(ToolbarItemLocation),}-pub trait ToolbarItemView: Render + EventEmitter<ToolbarItemEvent> {+pub trait ToolbarItemView: Render<Self> + EventEmitter<ToolbarItemEvent> {fn set_active_pane_item(&mut self,active_pane_item: Option<&dyn crate::ItemHandle>,@@ -51,7 +51,7 @@ pub struct Toolbar {items: Vec<(Box<dyn ToolbarItemViewHandle>, ToolbarItemLocation)>,}-impl Render for Toolbar {+impl Render<Self> for Toolbar {type Element = Div<Self>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rsindex af61091ce4c..e6b3f1875fb 100644--- a/crates/workspace2/src/workspace2.rs+++ b/crates/workspace2/src/workspace2.rs@@ -3592,7 +3592,7 @@ impl FocusableView for Workspace {}}-impl Render for Workspace {+impl Render<Self> for Workspace {type Element = Div<Self>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {