Skip to content

fix(scroll): virtual list anchor shifts carry a running glide's target with the offset - #1456

Merged
Hona merged 1 commit into
devfrom
fix/364-virtual-glide-anchor
Nov 23, 2026
Merged

Hona merged 1 commit into
devfrom
fix/364-virtual-glide-anchor

Conversation

@Hona

@Hona Hona commented Nov 23, 2026

Copy link
Copy Markdown
Member

Refs #364

Cause

When a virtual list inserts rows above the viewport or measures previously estimated rows above its anchor, crates/rune/src/runtime/commit/measure.rs (measure_virtuals, window) and crates/rune/src/runtime/commit/remount.rs (remount_virtuals) shift ScrollState::offset by VirtualList::anchor_delta(), but leave a running ScrollMode::Glide { to: GlideTo::Offset(to) | GlideTo::ShrunkEnd(to), .. } target unchanged. On the next frame scroll_bottom::glide continues gliding toward the unshifted offset and overshoots by the anchor delta.

Changes

  • Added ScrollState::shift_anchor(delta: f32) in crates/rune/src/runtime/scroll/offset.rs to shift offset and any running GlideTo::Offset / GlideTo::ShrunkEnd target together (both clamped >= 0.0), leaving GlideTo::Bottom dynamic against st.max.
  • Called st.shift_anchor(..) at the three virtual-list anchor adjustment sites in crates/rune/src/runtime/commit/measure.rs and crates/rune/src/runtime/commit/remount.rs.
  • Added regression tests virtual_list_prepend_mid_glide_shifts_glide_target and virtual_list_measure_above_mid_glide_shifts_glide_target in crates/rune/src/runtime/tests/scroll_growth.rs.
  • Added changelog/unreleased/2026-11-23-virtual-glide-anchor.md.
  • Leaves Virtual list: shift a running glide's target with the anchor, and anchor on a row the app marks #364 open for the remaining feature request (marking rows as eligible or ineligible scroll anchors) and the offset-0 anchoring question.

Verification

  • Verified both new tests fail without the fix and pass with it: cargo test -p rune -p rune-mermaid -p rune-kit --features rune-kit/markdown,rune-kit/mermaid scroll_growth (21 passed), plus runtime::scroll:: (80 passed), remount (8 passed), scroll_retarget (5 passed), and integration scroll_to (9 passed).
  • scripts/file-size.sh: 0 errors.
  • Shared runtime code only (no platform-specific cfg blocks touched); checked on Windows only.

@Hona
Hona merged commit 2800965 into dev Nov 23, 2026
1 check passed
@Hona
Hona deleted the fix/364-virtual-glide-anchor branch November 23, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant