Skip to content

fix(native): size the review scrollbar from measured card heights - #843

Merged
omartelo merged 1 commit into
mainfrom
fix/native-review-scrollbar-size
Oct 19, 2026
Merged

omartelo merged 1 commit into
mainfrom
fix/native-review-scrollbar-size

Conversation

@omartelo

Copy link
Copy Markdown
Collaborator

Problem

In the native window's Review (and a pull request's Files tab, the same panel), the scrollbar thumb grew and shrank depending on which file filled the view: large at the top beside short files, tiny while scrolling through a long one.

Each list item is a whole file card, and layout.List estimates the list's length as the visible items' average height times their count, which material.ListStyle draws the thumb from. Cards of very different heights swing that estimate with every scroll. The scrollbar drag had the same flaw: it moved by item count, so a 6-line card and a 250-line one were the same drag distance.

Fix

  • reviewPanel keeps each card's last measured height (itemHeights), reset when something resizes every card at once: width, split, hiding whitespace, collapse/expand all, font, or the number of files.
  • The thumb comes from those heights (scrollSpan); a card not laid out yet counts as the average of the measured ones, since godemirror does not expose a diff's row count.
  • The list is laid out with layout.List + material.Scrollbar in place of ListStyle, and dragging the bar moves Position.Offset in pixels over the measured total.

Known limit: the thumb may adjust once when a file not seen yet is first laid out and its real height replaces the estimate.

Verification

  • native/: gofmt -l ., go vet ./..., go test ./... clean; new tests in dock_review_scroll_test.go pin the thumb's length across uneven cards, the average for unmeasured cards, clamping and the reset rule.
  • No -shot: it opens on a session, not the Review tab, and cannot scroll; needs a look in a real window.

layout.List estimates the list's length as its visible items' average
times their count. Each Review item is a whole file card, so a 6-line card
beside a 250-line one swung that estimate, and the thumb, with every
scroll. The panel now remembers each card's measured height, counts an
unmeasured one as the average, and draws the bar and its drag from that
total.
@omartelo
omartelo merged commit 156621a into main Oct 19, 2026
10 checks passed
@omartelo
omartelo deleted the fix/native-review-scrollbar-size branch October 19, 2026 21:16
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