feat: use uniform list for tree component
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s

This commit is contained in:
2026-11-25 08:35:23 +07:00
parent bf06d29c2e
commit e54364b716
5 changed files with 218 additions and 189 deletions
+31 -35
View File
@@ -260,42 +260,38 @@ impl RepoFilesView {
let change_view = view.clone();
let disclosure_view = view;
div()
.flex_1()
.min_h_0()
.w_full()
.child(
Tree::new("repo-tree")
.selected(selected)
.items(move |_, _| Arc::clone(&rows))
.on_change({
let view = change_view;
move |index, window, cx| {
if let Some(index) = index
&& let Err(error) = view.update(cx, |this, cx| {
this.activate_row(index, window, cx);
})
{
log::warn!("failed to activate tree row: {error}");
}
// Mirrors the sidebar's left inset, so rows stay aligned while the scrollbar hugs its border.
Tree::new("repo-tree")
.pr_2()
.selected(selected)
.items(move |_, _| Arc::clone(&rows))
.on_change({
let view = change_view;
move |index, window, cx| {
if let Some(index) = index
&& let Err(error) = view.update(cx, |this, cx| {
this.activate_row(index, window, cx);
})
{
log::warn!("failed to activate tree row: {error}");
}
}
})
.on_disclosure({
let view = disclosure_view;
move |index, _, cx| {
if let Err(error) = view.update(cx, |this, cx| {
let id = this.rows.get(index).map(|row| row.key().to_string());
if let Some(id) = id {
this.toggle_folder(&id);
cx.emit(RepoFilesEvent::Activated);
cx.notify();
}
})
.on_disclosure({
let view = disclosure_view;
move |index, _, cx| {
if let Err(error) = view.update(cx, |this, cx| {
let id = this.rows.get(index).map(|row| row.key().to_string());
if let Some(id) = id {
this.toggle_folder(&id);
cx.emit(RepoFilesEvent::Activated);
cx.notify();
}
}) {
log::warn!("failed to toggle folder: {error}");
}
}
}),
)
}) {
log::warn!("failed to toggle folder: {error}");
}
}
})
.into_any_element()
}
+33 -31
View File
@@ -6,9 +6,8 @@ use anyhow::Error;
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
ParentElement as _, PathPromptOptions, Render, SharedString, StatefulInteractiveElement as _,
StyleRefinement, Styled as _, Subscription, SystemNotification, Task, WeakEntity, Window, div,
px,
ParentElement as _, PathPromptOptions, Render, SharedString, StyleRefinement, Styled as _,
Subscription, SystemNotification, Task, WeakEntity, Window, div, px,
};
use metadata::ProfileDirectory;
use nostr::prelude::{PublicKey, Url};
@@ -1441,42 +1440,45 @@ impl RepoDetailView {
let commit_id = commit.id.clone();
Some(
h_flex()
.id("last-commit")
.h_8()
.px_2()
.gap_2()
.min_w_0()
.rounded(cx.theme().radius.control)
.hover(|this| this.bg(cx.theme().colors.muted_hover))
Button::new("last-commit")
.variant(ButtonVariant::Ghost)
.fully_rounded(true)
.tooltip(Tooltip::text("View latest commit"))
.on_click(move |_, window, cx| {
history.update(cx, |history, cx| {
history.open_commit_diff(&commit_id, window, cx);
});
})
.child(Icon::named(IconRole::GitCommit).color(cx.theme().colors.muted_foreground))
.child(
div()
.font_family(cx.theme().mono_font)
.text_sm()
.text_color(cx.theme().colors.muted_foreground)
.child(SharedString::from(short)),
)
.child(
div()
.max_w(px(220.))
.text_sm()
.text_ellipsis()
.whitespace_nowrap()
.child(commit.summary.clone()),
)
.child(
div()
.text_sm()
.text_color(cx.theme().colors.muted_foreground)
.child(relative_time_secs(commit.time)),
h_flex()
.w_full()
.gap_2()
.child(
Icon::named(IconRole::GitCommit)
.color(cx.theme().colors.muted_foreground),
)
.child(
div()
.text_sm()
.text_color(cx.theme().colors.muted_foreground)
.child(SharedString::from(&short)),
)
.child(
div()
.max_w(px(220.))
.text_sm()
.text_ellipsis()
.whitespace_nowrap()
.child(SharedString::from(&commit.summary)),
)
.child(
div()
.text_sm()
.text_color(cx.theme().colors.muted_foreground)
.child(SharedString::from(relative_time_secs(commit.time))),
),
)
.flex_1()
.into_any_element(),
)
}