Simplify ListState API (#35685)

Follow up to: https://github.com/zed-industries/zed/pull/35670,
simplifies the List state APIs so you no longer have to worry about
strong vs. weak pointers when rendering list items.

Release Notes:

- N/A

---------

Co-authored-by: Agus Zubiaga <agus@zed.dev>
This commit is contained in:
Mikayla Maki 2025-08-05 17:02:26 -07:00 committed by GitHub
parent d0de81b0b4
commit 53175263a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 322 additions and 403 deletions

View file

@ -115,21 +115,9 @@ impl ProjectIndexDebugView {
.collect::<Vec<_>>();
this.update(cx, |this, cx| {
let view = cx.entity().downgrade();
this.selected_path = Some(PathState {
path: file_path,
list_state: ListState::new(
chunks.len(),
gpui::ListAlignment::Top,
px(100.),
move |ix, _, cx| {
if let Some(view) = view.upgrade() {
view.update(cx, |view, cx| view.render_chunk(ix, cx))
} else {
div().into_any()
}
},
),
list_state: ListState::new(chunks.len(), gpui::ListAlignment::Top, px(100.)),
chunks,
});
cx.notify();
@ -219,7 +207,13 @@ impl Render for ProjectIndexDebugView {
cx.notify();
})),
)
.child(list(selected_path.list_state.clone()).size_full())
.child(
list(
selected_path.list_state.clone(),
cx.processor(|this, ix, _, cx| this.render_chunk(ix, cx)),
)
.size_full(),
)
.size_full()
.into_any_element()
} else {