diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 73db830204..dc2a604f28 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>> { + ) -> Option>> { 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) as Box]; + vec![Box::new(filename_label.into_root(cx)) as Box]; 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, - ) as Box + .into_root(cx) as Element, + ) as Box })); Some(breadcrumbs) } diff --git a/crates/gpui/src/elements.rs b/crates/gpui/src/elements.rs index 7096470193..a13c7ccf07 100644 --- a/crates/gpui/src/elements.rs +++ b/crates/gpui/src/elements.rs @@ -128,6 +128,16 @@ pub trait Drawable { } } + fn into_root(self, cx: &ViewContext) -> RootElement + where + Self: 'static + Sized, + { + RootElement { + element: self.boxed(), + view: cx.handle().downgrade(), + } + } + fn named(self, name: impl Into>) -> Element where Self: 'static + Sized, diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 1277d8e227..85bf1d58d8 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>> { + fn breadcrumbs( + &self, + _theme: &Theme, + _cx: &ViewContext, + ) -> Option>> { None } @@ -221,7 +225,7 @@ pub trait ItemHandle: 'static + fmt::Debug { ) -> gpui::Subscription; fn to_searchable_item_handle(&self, cx: &AppContext) -> Option>; fn breadcrumb_location(&self, cx: &AppContext) -> ToolbarItemLocation; - fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option>>; + fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option>>; fn serialized_item_kind(&self) -> Option<&'static str>; fn show_toolbar(&self, cx: &AppContext) -> bool; } @@ -591,7 +595,7 @@ impl ItemHandle for ViewHandle { self.read(cx).breadcrumb_location() } - fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option>> { + fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option>> { self.read(cx).breadcrumbs(theme, cx) }