Unified · Split
| @@ -598,20 +598,30 @@ mod test { · 597 unmodified lines | ||
| 598 | 598 | div().h(px(10.)).w_full().into_any() |
| 599 | 599 | }); |
| 600 | 600 | |
| 601 | + // Ensure that the list is scrolled to the top | |
| 602 | + state.scroll_to(gpui::ListOffset { | |
| 603 | + item_ix: 0, | |
| 604 | + offset_in_item: px(0.0), | |
| 605 | + }); | |
| 606 | + | |
| 607 | + // Paint | |
| 601 | 608 | cx.draw( |
| 602 | 609 | point(px(0.), px(0.)), |
| 603 | 610 | size(px(100.), px(20.)).into(), |
| 604 | 611 | |_| list(state.clone()).w_full().h_full().z_index(10).into_any(), |
| 605 | 612 | ); |
| 606 | 613 | |
| 614 | + // Reset | |
| 607 | 615 | state.reset(5); |
| 608 | 616 | |
| 617 | + // And then recieve a scroll event _before_ the next paint | |
| 609 | 618 | cx.simulate_event(ScrollWheelEvent { |
| 610 | 619 | position: point(px(1.), px(1.)), |
| 611 | 620 | delta: ScrollDelta::Pixels(point(px(0.), px(-500.))), |
| 612 | 621 | ..Default::default() |
| 613 | 622 | }); |
| 614 | 623 | |
| 624 | + // Scroll position should stay at the top of the list | |
| 615 | 625 | assert_eq!(state.logical_scroll_top().item_ix, 0); |
| 616 | 626 | assert_eq!(state.logical_scroll_top().offset_in_item, px(0.)); |
| 617 | 627 | |