Make breadcrumb content scrollable (#22309)
Part of https://github.com/zed-industries/zed/issues/5363 https://github.com/user-attachments/assets/66c90cb7-1b36-4436-ad1e-344fbcd4befc Release Notes: - N/A
This commit is contained in:
parent
9b2bc458e3
commit
fadf9ff4f4
1 changed files with 12 additions and 3 deletions
|
@ -39,10 +39,17 @@ impl EventEmitter<ToolbarItemEvent> for Breadcrumbs {}
|
||||||
impl Render for Breadcrumbs {
|
impl Render for Breadcrumbs {
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||||
const MAX_SEGMENTS: usize = 12;
|
const MAX_SEGMENTS: usize = 12;
|
||||||
let element = h_flex().text_ui(cx);
|
|
||||||
|
let element = h_flex()
|
||||||
|
.id("breadcrumb-container")
|
||||||
|
.flex_grow()
|
||||||
|
.overflow_x_scroll()
|
||||||
|
.text_ui(cx);
|
||||||
|
|
||||||
let Some(active_item) = self.active_item.as_ref() else {
|
let Some(active_item) = self.active_item.as_ref() else {
|
||||||
return element;
|
return element;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(mut segments) = active_item.breadcrumbs(cx.theme(), cx) else {
|
let Some(mut segments) = active_item.breadcrumbs(cx.theme(), cx) else {
|
||||||
return element;
|
return element;
|
||||||
};
|
};
|
||||||
|
@ -52,6 +59,7 @@ impl Render for Breadcrumbs {
|
||||||
prefix_end_ix,
|
prefix_end_ix,
|
||||||
segments.len().saturating_sub(MAX_SEGMENTS / 2),
|
segments.len().saturating_sub(MAX_SEGMENTS / 2),
|
||||||
);
|
);
|
||||||
|
|
||||||
if suffix_start_ix > prefix_end_ix {
|
if suffix_start_ix > prefix_end_ix {
|
||||||
segments.splice(
|
segments.splice(
|
||||||
prefix_end_ix..suffix_start_ix,
|
prefix_end_ix..suffix_start_ix,
|
||||||
|
@ -82,6 +90,7 @@ impl Render for Breadcrumbs {
|
||||||
});
|
});
|
||||||
|
|
||||||
let breadcrumbs_stack = h_flex().gap_1().children(breadcrumbs);
|
let breadcrumbs_stack = h_flex().gap_1().children(breadcrumbs);
|
||||||
|
|
||||||
match active_item
|
match active_item
|
||||||
.downcast::<Editor>()
|
.downcast::<Editor>()
|
||||||
.map(|editor| editor.downgrade())
|
.map(|editor| editor.downgrade())
|
||||||
|
@ -102,14 +111,14 @@ impl Render for Breadcrumbs {
|
||||||
if let Some(editor) = editor.upgrade() {
|
if let Some(editor) = editor.upgrade() {
|
||||||
let focus_handle = editor.read(cx).focus_handle(cx);
|
let focus_handle = editor.read(cx).focus_handle(cx);
|
||||||
Tooltip::for_action_in(
|
Tooltip::for_action_in(
|
||||||
"Show symbol outline",
|
"Show Symbol Outline",
|
||||||
&editor::actions::ToggleOutline,
|
&editor::actions::ToggleOutline,
|
||||||
&focus_handle,
|
&focus_handle,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Tooltip::for_action(
|
Tooltip::for_action(
|
||||||
"Show symbol outline",
|
"Show Symbol Outline",
|
||||||
&editor::actions::ToggleOutline,
|
&editor::actions::ToggleOutline,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue