Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Nathan Sobo4cb13fb39cf1
diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rsindex 73db8302042..dc2a604f286 100644--- a/crates/editor/src/items.rs+++ b/crates/editor/src/items.rs@@ -7,8 +7,8 @@ use anyhow::{anyhow, Context, Result};use collections::HashSet;use futures::future::try_join_all;use gpui::{- elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, RenderedView,- Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,+ elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, Subscription, Task,+ View, ViewContext, ViewHandle, WeakViewHandle,};use language::{proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,@@ -731,7 +731,7 @@ impl Item for Editor {&self,theme: &theme::Theme,cx: &AppContext,- ) -> Option<Vec<Box<dyn RenderedView>>> {+ ) -> Option<Vec<Box<dyn AnyRootElement>>> {let cursor = self.selections.newest_anchor().head();let multibuffer = &self.buffer().read(cx);let (buffer_id, symbols) =@@ -753,7 +753,7 @@ impl Item for Editor {let filename_label = Label::new(filename, theme.workspace.breadcrumbs.default.text.clone());let mut breadcrumbs =- vec![Box::new(filename_label.boxed() as Element<Editor>) as Box<dyn RenderedView>];+ vec![Box::new(filename_label.into_root(cx)) as Box<dyn AnyRootElement>];breadcrumbs.extend(symbols.into_iter().map(|symbol| {Box::new(Text::new(@@ -761,8 +761,8 @@ impl Item for Editor {theme.workspace.breadcrumbs.default.text.clone(),).with_highlights(symbol.highlight_ranges)- .boxed() as Element<Editor>,- ) as Box<dyn RenderedView>+ .into_root(cx) as Element<Editor>,+ ) as Box<dyn AnyRootElement>}));Some(breadcrumbs)}diff --git a/crates/gpui/src/elements.rs b/crates/gpui/src/elements.rsindex 7096470193e..a13c7ccf075 100644--- a/crates/gpui/src/elements.rs+++ b/crates/gpui/src/elements.rs@@ -128,6 +128,16 @@ pub trait Drawable<V: View> {}}+ fn into_root(self, cx: &ViewContext<V>) -> RootElement<V>+ where+ Self: 'static + Sized,+ {+ RootElement {+ element: self.boxed(),+ view: cx.handle().downgrade(),+ }+ }+fn named(self, name: impl Into<Cow<'static, str>>) -> Element<V>whereSelf: 'static + Sized,diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rsindex 1277d8e2276..85bf1d58d89 100644--- a/crates/workspace/src/item.rs+++ b/crates/workspace/src/item.rs@@ -15,8 +15,8 @@ use std::{use anyhow::Result;use client::{proto, Client};use gpui::{- AnyViewHandle, AppContext, Element, ModelHandle, RenderedView, Task, View, ViewContext,- ViewHandle, WeakViewHandle,+ elements::AnyRootElement, AnyViewHandle, AppContext, Element, ModelHandle, Task, View,+ ViewContext, ViewHandle, WeakViewHandle,};use project::{Project, ProjectEntryId, ProjectPath};use settings::{Autosave, Settings};@@ -134,7 +134,11 @@ pub trait Item: View {ToolbarItemLocation::Hidden}- fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>> {+ fn breadcrumbs(+ &self,+ _theme: &Theme,+ _cx: &ViewContext<Self>,+ ) -> Option<Vec<Box<dyn AnyRootElement>>> {None}@@ -221,7 +225,7 @@ pub trait ItemHandle: 'static + fmt::Debug {) -> gpui::Subscription;fn to_searchable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>>;fn breadcrumb_location(&self, cx: &AppContext) -> ToolbarItemLocation;- fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>>;+ fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn AnyRootElement>>>;fn serialized_item_kind(&self) -> Option<&'static str>;fn show_toolbar(&self, cx: &AppContext) -> bool;}@@ -591,7 +595,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {self.read(cx).breadcrumb_location()}- fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>> {+ fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn AnyRootElement>>> {self.read(cx).breadcrumbs(theme, cx)}