Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix regressions in `List` (#10924)
Antonio Scandurrafbc6e930a77e
diff --git a/crates/gpui/src/elements/list.rs b/crates/gpui/src/elements/list.rsindex 784955a5d76..a6f65e9469c 100644--- a/crates/gpui/src/elements/list.rs+++ b/crates/gpui/src/elements/list.rs@@ -202,13 +202,14 @@ impl ListState {////// Note that this will cause scroll events to be dropped until the next paint.pub fn reset(&self, element_count: usize) {- {+ let old_count = {let state = &mut *self.0.borrow_mut();state.reset = true;state.logical_scroll_top = None;- }+ state.items.summary().count+ };- self.splice(0..element_count, element_count);+ self.splice(0..old_count, element_count);}/// The number of items in this list.@@ -613,6 +614,9 @@ impl StateInner {let mut layout_response =self.layout_items(Some(bounds.size.width), bounds.size.height, &padding, cx);+ // Avoid honoring autoscroll requests from elements other than our children.+ cx.take_autoscroll();+// Only paint the visible items, if there is actually any space for them (taking padding into account)if bounds.size.height > padding.top + padding.bottom {let mut item_origin = bounds.origin + Point::new(px(0.), padding.top);