Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix stale scroll position in tab bar
Antonio Scandurrab38a09526c5d
diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rsindex 74b414bb03a..7bda5966f59 100644--- a/crates/gpui2/src/elements/div.rs+++ b/crates/gpui2/src/elements/div.rs@@ -1467,6 +1467,14 @@ impl Interactivity {.clone();let line_height = cx.line_height();let scroll_max = (content_size - bounds.size).max(&Size::default());+ // Clamp scroll offset in case scroll max is smaller now (e.g., if children+ // were removed or the bounds became larger).+ {+ let mut scroll_offset = scroll_offset.borrow_mut();+ scroll_offset.x = scroll_offset.x.clamp(-scroll_max.width, px(0.));+ scroll_offset.y = scroll_offset.x.clamp(-scroll_max.height, px(0.));+ }+let interactive_bounds = interactive_bounds.clone();cx.on_mouse_event(move |event: &ScrollWheelEvent, phase, cx| {if phase == DispatchPhase::Bubble