From 49bc2e61dae206c1848f10e87f09b9368eab726b Mon Sep 17 00:00:00 2001 From: maan2003 <49202620+maan2003@users.noreply.github.com> Date: Tue, 1 Jul 2025 12:14:19 +0530 Subject: [PATCH] gpui: Fix slow scrolling in lists (#33608) matches editor element's behavior https://github.com/user-attachments/assets/f70912e1-5adb-403b-a98c-63e2e89929ac - in first version editor scrolls like 1.5 pages, but agent panel only scrolls half a page. - in second version, agent panel also scrolls like 1.5 pages. Release Notes: - Fixed skipping of some scroll events in the non-uniform list UI element, which fixes slow scrolling of the agent panel. --- crates/gpui/src/elements/list.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/elements/list.rs b/crates/gpui/src/elements/list.rs index 6b9df6ab29..c9a08e968a 100644 --- a/crates/gpui/src/elements/list.rs +++ b/crates/gpui/src/elements/list.rs @@ -10,8 +10,8 @@ use crate::{ AnyElement, App, AvailableSpace, Bounds, ContentMask, DispatchPhase, Edges, Element, EntityId, FocusHandle, GlobalElementId, Hitbox, HitboxBehavior, InspectorElementId, IntoElement, - Overflow, Pixels, Point, ScrollWheelEvent, Size, Style, StyleRefinement, Styled, Window, point, - px, size, + Overflow, Pixels, Point, ScrollDelta, ScrollWheelEvent, Size, Style, StyleRefinement, Styled, + Window, point, px, size, }; use collections::VecDeque; use refineable::Refineable as _; @@ -962,12 +962,15 @@ impl Element for List { let height = bounds.size.height; let scroll_top = prepaint.layout.scroll_top; let hitbox_id = prepaint.hitbox.id; + let mut accumulated_scroll_delta = ScrollDelta::default(); window.on_mouse_event(move |event: &ScrollWheelEvent, phase, window, cx| { if phase == DispatchPhase::Bubble && hitbox_id.should_handle_scroll(window) { + accumulated_scroll_delta = accumulated_scroll_delta.coalesce(event.delta); + let pixel_delta = accumulated_scroll_delta.pixel_delta(px(20.)); list_state.0.borrow_mut().scroll( &scroll_top, height, - event.delta.pixel_delta(px(20.)), + pixel_delta, current_view, window, cx,