gpui: Simplify uniform list API by removing entity param (#32480)

This PR also introduces `Context::processor`, a sibling of
`Context::listener` that takes a strong pointer to entity and allows for
a return result.

Release Notes:

- N/A

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Ben Kunkle 2025-06-10 13:50:57 -05:00 committed by GitHub
parent c55630889a
commit f567bb52ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 80 additions and 77 deletions

View file

@ -17,7 +17,7 @@ use gpui::{
use head::Head;
use schemars::JsonSchema;
use serde::Deserialize;
use std::{sync::Arc, time::Duration};
use std::{ops::Range, sync::Arc, time::Duration};
use ui::{
Color, Divider, Label, ListItem, ListItemSpacing, Scrollbar, ScrollbarState, prelude::*, v_flex,
};
@ -760,14 +760,13 @@ impl<D: PickerDelegate> Picker<D> {
match &self.element_container {
ElementContainer::UniformList(scroll_handle) => uniform_list(
cx.entity().clone(),
"candidates",
self.delegate.match_count(),
move |picker, visible_range, window, cx| {
cx.processor(move |picker, visible_range: Range<usize>, window, cx| {
visible_range
.map(|ix| picker.render_element(window, cx, ix))
.collect()
},
}),
)
.with_sizing_behavior(sizing_behavior)
.when_some(self.widest_item, |el, widest_item| {