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()
}