From 3bc4b584b17b1b2858021ceef52dd27cfeb9cd83 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 13 Mar 2026 09:00:22 +0100 Subject: [PATCH] editor: Replace `BreadcrumbText` with `HighlightedText` (#51083) Remove the BreadcrumbText struct from workspace and use the existing HighlightedText struct from the language crate instead. The per-segment font field is replaced by returning an optional Font alongside the segments from the breadcrumbs() method, since the font was always uniform across all segments of a given item. Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/breadcrumbs/src/breadcrumbs.rs | 10 +++--- .../collab/tests/integration/editor_tests.rs | 3 +- crates/editor/src/editor.rs | 19 +++++----- crates/editor/src/element.rs | 36 ++++++++++--------- crates/editor/src/items.rs | 15 ++++---- crates/editor/src/split.rs | 10 +++--- crates/git_ui/src/file_diff_view.rs | 8 ++--- crates/git_ui/src/file_history_view.rs | 5 ++- crates/git_ui/src/multi_diff_view.rs | 8 ++--- crates/image_viewer/src/image_viewer.rs | 28 ++++++++------- crates/terminal_view/src/terminal_view.rs | 18 +++++----- crates/workspace/src/item.rs | 20 ++++------- 12 files changed, 93 insertions(+), 87 deletions(-) diff --git a/crates/breadcrumbs/src/breadcrumbs.rs b/crates/breadcrumbs/src/breadcrumbs.rs index 54a5e40337dc4b41ddd668783656498e9be841b9..a63a332e4a0e38e4b65020bf77f94f78600594d3 100644 --- a/crates/breadcrumbs/src/breadcrumbs.rs +++ b/crates/breadcrumbs/src/breadcrumbs.rs @@ -1,14 +1,15 @@ use gpui::{ - AnyElement, App, Context, EventEmitter, Global, IntoElement, Render, Subscription, Window, + AnyElement, App, Context, EventEmitter, Font, Global, IntoElement, Render, Subscription, Window, }; use ui::prelude::*; use workspace::{ ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, - item::{BreadcrumbText, ItemEvent, ItemHandle}, + item::{HighlightedText, ItemEvent, ItemHandle}, }; type RenderBreadcrumbTextFn = fn( - Vec, + Vec, + Option, Option, &dyn ItemHandle, bool, @@ -57,7 +58,7 @@ impl Render for Breadcrumbs { return element.into_any_element(); }; - let Some(segments) = active_item.breadcrumbs(cx) else { + let Some((segments, breadcrumb_font)) = active_item.breadcrumbs(cx) else { return element.into_any_element(); }; @@ -66,6 +67,7 @@ impl Render for Breadcrumbs { if let Some(render_fn) = cx.try_global::() { (render_fn.0)( segments, + breadcrumb_font, prefix_element, active_item.as_ref(), false, diff --git a/crates/collab/tests/integration/editor_tests.rs b/crates/collab/tests/integration/editor_tests.rs index 6b23780156e03d62543cf597e82959083685f0c0..1590f498308c74125c7672595cb7510b6653e9b1 100644 --- a/crates/collab/tests/integration/editor_tests.rs +++ b/crates/collab/tests/integration/editor_tests.rs @@ -5691,7 +5691,7 @@ async fn test_document_symbols(cx_a: &mut TestAppContext, cx_b: &mut TestAppCont executor.run_until_parked(); editor_a.update(cx_a, |editor, cx| { - let breadcrumbs = editor + let (breadcrumbs, _) = editor .breadcrumbs(cx) .expect("Host should have breadcrumbs"); let texts: Vec<_> = breadcrumbs.iter().map(|b| b.text.as_str()).collect(); @@ -5727,6 +5727,7 @@ async fn test_document_symbols(cx_a: &mut TestAppContext, cx_b: &mut TestAppCont editor .breadcrumbs(cx) .expect("Client B should have breadcrumbs") + .0 .iter() .map(|b| b.text.as_str()) .collect::>(), diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 20d976ad6c0e0a9c82fbaa681efea80f2873d375..7536e58d2f0dbfd58f738bdb8bed3b3c2a65a25e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -217,7 +217,7 @@ use workspace::{ CollaboratorId, Item as WorkspaceItem, ItemId, ItemNavHistory, NavigationEntry, OpenInTerminal, OpenTerminal, Pane, RestoreOnStartupBehavior, SERIALIZATION_THROTTLE_TIME, SplitDirection, TabBarSettings, Toast, ViewId, Workspace, WorkspaceId, WorkspaceSettings, - item::{BreadcrumbText, ItemBufferKind, ItemHandle, PreviewTabsSettings, SaveOptions}, + item::{ItemBufferKind, ItemHandle, PreviewTabsSettings, SaveOptions}, notifications::{DetachAndPromptErr, NotificationId, NotifyTaskExt}, searchable::SearchEvent, }; @@ -25323,14 +25323,13 @@ impl Editor { } } - fn breadcrumbs_inner(&self, cx: &App) -> Option> { + fn breadcrumbs_inner(&self, cx: &App) -> Option> { let multibuffer = self.buffer().read(cx); let is_singleton = multibuffer.is_singleton(); let (buffer_id, symbols) = self.outline_symbols_at_cursor.as_ref()?; let buffer = multibuffer.buffer(*buffer_id)?; let buffer = buffer.read(cx); - let settings = ThemeSettings::get_global(cx); // In a multi-buffer layout, we don't want to include the filename in the breadcrumbs let mut breadcrumbs = if is_singleton { let text = self.breadcrumb_header.clone().unwrap_or_else(|| { @@ -25351,19 +25350,17 @@ impl Editor { } }) }); - vec![BreadcrumbText { - text, - highlights: None, - font: Some(settings.buffer_font.clone()), + vec![HighlightedText { + text: text.into(), + highlights: vec![], }] } else { vec![] }; - breadcrumbs.extend(symbols.iter().map(|symbol| BreadcrumbText { - text: symbol.text.clone(), - highlights: Some(symbol.highlight_ranges.clone()), - font: Some(settings.buffer_font.clone()), + breadcrumbs.extend(symbols.iter().map(|symbol| HighlightedText { + text: symbol.text.clone().into(), + highlights: symbol.highlight_ranges.clone(), })); Some(breadcrumbs) } diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index dcbd00ef8c89de8c4a3e3334ae1804ebe9e7b042..ab00de0df25ca209604c7052367f0ac6ce2142ae 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -41,18 +41,18 @@ use git::{Oid, blame::BlameEntry, commit::ParsedCommitMessage, status::FileStatu use gpui::{ Action, Along, AnyElement, App, AppContext, AvailableSpace, Axis as ScrollbarAxis, BorderStyle, Bounds, ClickEvent, ClipboardItem, ContentMask, Context, Corner, Corners, CursorStyle, - DispatchPhase, Edges, Element, ElementInputHandler, Entity, Focusable as _, FontId, FontWeight, - GlobalElementId, Hitbox, HitboxBehavior, Hsla, InteractiveElement, IntoElement, IsZero, - KeybindingKeystroke, Length, Modifiers, ModifiersChangedEvent, MouseButton, MouseClickEvent, - MouseDownEvent, MouseMoveEvent, MousePressureEvent, MouseUpEvent, PaintQuad, ParentElement, - Pixels, PressureStage, ScrollDelta, ScrollHandle, ScrollWheelEvent, ShapedLine, SharedString, - Size, StatefulInteractiveElement, Style, Styled, StyledText, TextAlign, TextRun, + DispatchPhase, Edges, Element, ElementInputHandler, Entity, Focusable as _, Font, FontId, + FontWeight, GlobalElementId, Hitbox, HitboxBehavior, Hsla, InteractiveElement, IntoElement, + IsZero, KeybindingKeystroke, Length, Modifiers, ModifiersChangedEvent, MouseButton, + MouseClickEvent, MouseDownEvent, MouseMoveEvent, MousePressureEvent, MouseUpEvent, PaintQuad, + ParentElement, Pixels, PressureStage, ScrollDelta, ScrollHandle, ScrollWheelEvent, ShapedLine, + SharedString, Size, StatefulInteractiveElement, Style, Styled, StyledText, TextAlign, TextRun, TextStyleRefinement, WeakEntity, Window, anchored, deferred, div, fill, linear_color_stop, linear_gradient, outline, pattern_slash, point, px, quad, relative, size, solid_background, transparent_black, }; use itertools::Itertools; -use language::{IndentGuideSettings, language_settings::ShowWhitespaceSetting}; +use language::{HighlightedText, IndentGuideSettings, language_settings::ShowWhitespaceSetting}; use markdown::Markdown; use multi_buffer::{ Anchor, ExcerptId, ExcerptInfo, ExpandExcerptDirection, ExpandInfo, MultiBufferPoint, @@ -98,7 +98,7 @@ use util::{RangeExt, ResultExt, debug_panic}; use workspace::{ CollaboratorId, ItemHandle, ItemSettings, OpenInTerminal, OpenTerminal, RevealInProjectPanel, Workspace, - item::{BreadcrumbText, Item, ItemBufferKind}, + item::{Item, ItemBufferKind}, }; /// Determines what kinds of highlights should be applied to a lines background. @@ -7913,7 +7913,8 @@ impl EditorElement { } pub fn render_breadcrumb_text( - mut segments: Vec, + mut segments: Vec, + breadcrumb_font: Option, prefix: Option, active_item: &dyn ItemHandle, multibuffer_header: bool, @@ -7933,17 +7934,16 @@ pub fn render_breadcrumb_text( if suffix_start_ix > prefix_end_ix { segments.splice( prefix_end_ix..suffix_start_ix, - Some(BreadcrumbText { + Some(HighlightedText { text: "⋯".into(), - highlights: None, - font: None, + highlights: vec![], }), ); } let highlighted_segments = segments.into_iter().enumerate().map(|(index, segment)| { let mut text_style = window.text_style(); - if let Some(ref font) = segment.font { + if let Some(font) = &breadcrumb_font { text_style.font_family = font.family.clone(); text_style.font_features = font.features.clone(); text_style.font_style = font.style; @@ -7960,7 +7960,7 @@ pub fn render_breadcrumb_text( } StyledText::new(segment.text.replace('\n', " ")) - .with_default_highlights(&text_style, segment.highlights.unwrap_or_default()) + .with_default_highlights(&text_style, segment.highlights) .into_any() }); @@ -8070,13 +8070,13 @@ pub fn render_breadcrumb_text( } fn apply_dirty_filename_style( - segment: &BreadcrumbText, + segment: &HighlightedText, text_style: &gpui::TextStyle, cx: &App, ) -> Option { let text = segment.text.replace('\n', " "); - let filename_position = std::path::Path::new(&segment.text) + let filename_position = std::path::Path::new(segment.text.as_ref()) .file_name() .and_then(|f| { let filename_str = f.to_string_lossy(); @@ -8446,8 +8446,12 @@ pub(crate) fn render_buffer_header( el.child(Icon::new(IconName::FileLock).color(Color::Muted)) }) .when_some(breadcrumbs, |then, breadcrumbs| { + let font = theme::ThemeSettings::get_global(cx) + .buffer_font + .clone(); then.child(render_breadcrumb_text( breadcrumbs, + Some(font), None, editor_handle, true, diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 1a79414ddc3aa57397d964d4e0af0d87bedc9c3b..e0502e4d9987bef512506ef927ff5384be5f0c30 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -14,12 +14,12 @@ use fs::MTime; use futures::future::try_join_all; use git::status::GitSummary; use gpui::{ - AnyElement, App, AsyncWindowContext, Context, Entity, EntityId, EventEmitter, IntoElement, - ParentElement, Pixels, SharedString, Styled, Task, WeakEntity, Window, point, + AnyElement, App, AsyncWindowContext, Context, Entity, EntityId, EventEmitter, Font, + IntoElement, ParentElement, Pixels, SharedString, Styled, Task, WeakEntity, Window, point, }; use language::{ - Bias, Buffer, BufferRow, CharKind, CharScopeContext, LocalFile, Point, SelectionGoal, - proto::serialize_anchor as serialize_text_anchor, + Bias, Buffer, BufferRow, CharKind, CharScopeContext, HighlightedText, LocalFile, Point, + SelectionGoal, proto::serialize_anchor as serialize_text_anchor, }; use lsp::DiagnosticSeverity; use multi_buffer::MultiBufferOffset; @@ -56,7 +56,7 @@ use workspace::{ }; use workspace::{ OpenVisible, Pane, WorkspaceSettings, - item::{BreadcrumbText, FollowEvent, ProjectItemKind}, + item::{FollowEvent, ProjectItemKind}, searchable::SearchOptions, }; use zed_actions::preview::{ @@ -981,9 +981,10 @@ impl Item for Editor { } // In a non-singleton case, the breadcrumbs are actually shown on sticky file headers of the multibuffer. - fn breadcrumbs(&self, cx: &App) -> Option> { + fn breadcrumbs(&self, cx: &App) -> Option<(Vec, Option)> { if self.buffer.read(cx).is_singleton() { - self.breadcrumbs_inner(cx) + let font = theme::ThemeSettings::get_global(cx).buffer_font.clone(); + Some((self.breadcrumbs_inner(cx)?, Some(font))) } else { None } diff --git a/crates/editor/src/split.rs b/crates/editor/src/split.rs index 877f388fc3b783202cb29f8ca063446635e4277a..c9668bc35655dfcda62e71884a782b4edecae093 100644 --- a/crates/editor/src/split.rs +++ b/crates/editor/src/split.rs @@ -6,9 +6,11 @@ use std::{ use buffer_diff::{BufferDiff, BufferDiffSnapshot}; use collections::HashMap; -use gpui::{Action, AppContext as _, Entity, EventEmitter, Focusable, Subscription, WeakEntity}; +use gpui::{ + Action, AppContext as _, Entity, EventEmitter, Focusable, Font, Subscription, WeakEntity, +}; use itertools::Itertools; -use language::{Buffer, Capability}; +use language::{Buffer, Capability, HighlightedText}; use multi_buffer::{ Anchor, BufferOffset, ExcerptId, ExcerptRange, ExpandExcerptDirection, MultiBuffer, MultiBufferDiffHunk, MultiBufferPoint, MultiBufferSnapshot, PathKey, @@ -29,7 +31,7 @@ use crate::{ }; use workspace::{ ActivatePaneLeft, ActivatePaneRight, Item, ToolbarItemLocation, Workspace, - item::{BreadcrumbText, ItemBufferKind, ItemEvent, SaveOptions, TabContentParams}, + item::{ItemBufferKind, ItemEvent, SaveOptions, TabContentParams}, searchable::{SearchEvent, SearchToken, SearchableItem, SearchableItemHandle}, }; @@ -1853,7 +1855,7 @@ impl Item for SplittableEditor { self.rhs_editor.read(cx).breadcrumb_location(cx) } - fn breadcrumbs(&self, cx: &App) -> Option> { + fn breadcrumbs(&self, cx: &App) -> Option<(Vec, Option)> { self.rhs_editor.read(cx).breadcrumbs(cx) } diff --git a/crates/git_ui/src/file_diff_view.rs b/crates/git_ui/src/file_diff_view.rs index c684c230cf54cdbe89f13d9126c142e2dece3558..bdd5dee36e2d54888d081cfefed21602ecb8fa1b 100644 --- a/crates/git_ui/src/file_diff_view.rs +++ b/crates/git_ui/src/file_diff_view.rs @@ -6,9 +6,9 @@ use editor::{Editor, EditorEvent, MultiBuffer}; use futures::{FutureExt, select_biased}; use gpui::{ AnyElement, App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, FocusHandle, - Focusable, IntoElement, Render, Task, WeakEntity, Window, + Focusable, Font, IntoElement, Render, Task, WeakEntity, Window, }; -use language::{Buffer, LanguageRegistry}; +use language::{Buffer, HighlightedText, LanguageRegistry}; use project::Project; use std::{ any::{Any, TypeId}, @@ -21,7 +21,7 @@ use ui::{Color, Icon, IconName, Label, LabelCommon as _, SharedString}; use util::paths::PathExt as _; use workspace::{ Item, ItemHandle as _, ItemNavHistory, ToolbarItemLocation, Workspace, - item::{BreadcrumbText, ItemEvent, SaveOptions, TabContentParams}, + item::{ItemEvent, SaveOptions, TabContentParams}, searchable::SearchableItemHandle, }; @@ -324,7 +324,7 @@ impl Item for FileDiffView { ToolbarItemLocation::PrimaryLeft } - fn breadcrumbs(&self, cx: &App) -> Option> { + fn breadcrumbs(&self, cx: &App) -> Option<(Vec, Option)> { self.editor.breadcrumbs(cx) } diff --git a/crates/git_ui/src/file_history_view.rs b/crates/git_ui/src/file_history_view.rs index ffd600c32af5be8fe9f390b93b6f96911bfecb07..03cf6671a23524a0e514ee5c11f55d5eba666796 100644 --- a/crates/git_ui/src/file_history_view.rs +++ b/crates/git_ui/src/file_history_view.rs @@ -565,7 +565,10 @@ impl Item for FileHistoryView { false } - fn breadcrumbs(&self, _cx: &App) -> Option> { + fn breadcrumbs( + &self, + _cx: &App, + ) -> Option<(Vec, Option)> { None } diff --git a/crates/git_ui/src/multi_diff_view.rs b/crates/git_ui/src/multi_diff_view.rs index 6c4c236da869e479cd042e4ed4cf12c98d861a84..c5e456a1e43584fd6ec5da98b9f5134e9801ef5c 100644 --- a/crates/git_ui/src/multi_diff_view.rs +++ b/crates/git_ui/src/multi_diff_view.rs @@ -3,9 +3,9 @@ use buffer_diff::BufferDiff; use editor::{Editor, EditorEvent, MultiBuffer, multibuffer_context_lines}; use gpui::{ AnyElement, App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, FocusHandle, - Focusable, IntoElement, Render, SharedString, Task, Window, + Focusable, Font, IntoElement, Render, SharedString, Task, Window, }; -use language::{Buffer, Capability, OffsetRangeExt}; +use language::{Buffer, Capability, HighlightedText, OffsetRangeExt}; use multi_buffer::PathKey; use project::Project; use std::{ @@ -18,7 +18,7 @@ use util::paths::PathStyle; use util::rel_path::RelPath; use workspace::{ Item, ItemHandle as _, ItemNavHistory, ToolbarItemLocation, Workspace, - item::{BreadcrumbText, ItemEvent, SaveOptions, TabContentParams}, + item::{ItemEvent, SaveOptions, TabContentParams}, searchable::SearchableItemHandle, }; @@ -338,7 +338,7 @@ impl Item for MultiDiffView { ToolbarItemLocation::PrimaryLeft } - fn breadcrumbs(&self, cx: &App) -> Option> { + fn breadcrumbs(&self, cx: &App) -> Option<(Vec, Option)> { self.editor.breadcrumbs(cx) } diff --git a/crates/image_viewer/src/image_viewer.rs b/crates/image_viewer/src/image_viewer.rs index 291603b2b3f1544f6c60f9c3bdbbb87d3f77c424..729a2d9ce31cbe2165f0f66c15921e566d6878b4 100644 --- a/crates/image_viewer/src/image_viewer.rs +++ b/crates/image_viewer/src/image_viewer.rs @@ -10,10 +10,10 @@ use file_icons::FileIcons; use gpui::PinchEvent; use gpui::{ AnyElement, App, Bounds, Context, DispatchPhase, Element, ElementId, Entity, EventEmitter, - FocusHandle, Focusable, GlobalElementId, InspectorElementId, InteractiveElement, IntoElement, - LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, - Point, Render, ScrollDelta, ScrollWheelEvent, Style, Styled, Task, WeakEntity, Window, actions, - checkerboard, div, img, point, px, size, + FocusHandle, Focusable, Font, GlobalElementId, InspectorElementId, InteractiveElement, + IntoElement, LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, + ParentElement, Pixels, Point, Render, ScrollDelta, ScrollWheelEvent, Style, Styled, Task, + WeakEntity, Window, actions, checkerboard, div, img, point, px, size, }; use language::File as _; use persistence::IMAGE_VIEWER; @@ -26,7 +26,7 @@ use workspace::{ ItemId, ItemSettings, Pane, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, Workspace, WorkspaceId, delete_unloaded_items, invalid_item_view::InvalidItemView, - item::{BreadcrumbText, Item, ItemHandle, ProjectItem, SerializableItem, TabContentParams}, + item::{HighlightedText, Item, ItemHandle, ProjectItem, SerializableItem, TabContentParams}, }; pub use crate::image_info::*; @@ -530,15 +530,17 @@ impl Item for ImageView { } } - fn breadcrumbs(&self, cx: &App) -> Option> { + fn breadcrumbs(&self, cx: &App) -> Option<(Vec, Option)> { let text = breadcrumbs_text_for_image(self.project.read(cx), self.image_item.read(cx), cx); - let settings = ThemeSettings::get_global(cx); - - Some(vec![BreadcrumbText { - text, - highlights: None, - font: Some(settings.buffer_font.clone()), - }]) + let font = ThemeSettings::get_global(cx).buffer_font.clone(); + + Some(( + vec![HighlightedText { + text: text.into(), + highlights: vec![], + }], + Some(font), + )) } fn can_split(&self) -> bool { diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index e4ed410ef79897770d2a27aaef10017b1d284390..c1a6542fbc17526eed4914815738212cf74eca8f 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -9,7 +9,7 @@ use assistant_slash_command::SlashCommandRegistry; use editor::{Editor, EditorSettings, actions::SelectAll, blink_manager::BlinkManager}; use gpui::{ Action, AnyElement, App, ClipboardEntry, DismissEvent, Entity, EventEmitter, ExternalPaths, - FocusHandle, Focusable, KeyContext, KeyDownEvent, Keystroke, MouseButton, MouseDownEvent, + FocusHandle, Focusable, Font, KeyContext, KeyDownEvent, Keystroke, MouseButton, MouseDownEvent, Pixels, Point, Render, ScrollWheelEvent, Styled, Subscription, Task, WeakEntity, actions, anchored, deferred, div, }; @@ -55,7 +55,7 @@ use workspace::{ CloseActiveItem, DraggedSelection, DraggedTab, NewCenterTerminal, NewTerminal, Pane, ToolbarItemLocation, Workspace, WorkspaceId, delete_unloaded_items, item::{ - BreadcrumbText, Item, ItemEvent, SerializableItem, TabContentParams, TabTooltipContent, + HighlightedText, Item, ItemEvent, SerializableItem, TabContentParams, TabTooltipContent, }, register_serializable_item, searchable::{ @@ -1655,12 +1655,14 @@ impl Item for TerminalView { } } - fn breadcrumbs(&self, cx: &App) -> Option> { - Some(vec![BreadcrumbText { - text: self.terminal().read(cx).breadcrumb_text.clone(), - highlights: None, - font: None, - }]) + fn breadcrumbs(&self, cx: &App) -> Option<(Vec, Option)> { + Some(( + vec![HighlightedText { + text: self.terminal().read(cx).breadcrumb_text.clone().into(), + highlights: vec![], + }], + None, + )) } fn added_to_workspace( diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 09c99c230a0c7a9710e2976ac0673b639d8e36c4..d4d31739779e7872e29005b180f2e4682ef808af 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -12,10 +12,11 @@ use client::{Client, proto}; use futures::{StreamExt, channel::mpsc}; use gpui::{ Action, AnyElement, AnyEntity, AnyView, App, AppContext, Context, Entity, EntityId, - EventEmitter, FocusHandle, Focusable, Font, HighlightStyle, Pixels, Point, Render, - SharedString, Task, WeakEntity, Window, + EventEmitter, FocusHandle, Focusable, Font, Pixels, Point, Render, SharedString, Task, + WeakEntity, Window, }; use language::Capability; +pub use language::HighlightedText; use project::{Project, ProjectEntryId, ProjectPath}; pub use settings::{ ActivateOnClose, ClosePosition, RegisterSetting, Settings, SettingsLocation, ShowCloseButton, @@ -25,7 +26,6 @@ use smallvec::SmallVec; use std::{ any::{Any, TypeId}, cell::RefCell, - ops::Range, path::Path, rc::Rc, sync::Arc, @@ -124,14 +124,6 @@ pub enum ItemEvent { Edit, } -// TODO: Combine this with existing HighlightedText struct? -#[derive(Debug)] -pub struct BreadcrumbText { - pub text: String, - pub highlights: Option, HighlightStyle)>>, - pub font: Option, -} - #[derive(Clone, Copy, Default, Debug)] pub struct TabContentParams { pub detail: Option, @@ -329,7 +321,7 @@ pub trait Item: Focusable + EventEmitter + Render + Sized { ToolbarItemLocation::Hidden } - fn breadcrumbs(&self, _cx: &App) -> Option> { + fn breadcrumbs(&self, _cx: &App) -> Option<(Vec, Option)> { None } @@ -548,7 +540,7 @@ pub trait ItemHandle: 'static + Send { ) -> gpui::Subscription; fn to_searchable_item_handle(&self, cx: &App) -> Option>; fn breadcrumb_location(&self, cx: &App) -> ToolbarItemLocation; - fn breadcrumbs(&self, cx: &App) -> Option>; + fn breadcrumbs(&self, cx: &App) -> Option<(Vec, Option)>; fn breadcrumb_prefix(&self, window: &mut Window, cx: &mut App) -> Option; fn show_toolbar(&self, cx: &App) -> bool; fn pixel_position_of_cursor(&self, cx: &App) -> Option>; @@ -1090,7 +1082,7 @@ impl ItemHandle for Entity { self.read(cx).breadcrumb_location(cx) } - fn breadcrumbs(&self, cx: &App) -> Option> { + fn breadcrumbs(&self, cx: &App) -> Option<(Vec, Option)> { self.read(cx).breadcrumbs(cx) }