Repository navigation
fix(native): size the review scrollbar from measured card heights - #843
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Listestimates the list's length as the visible items' average height times their count, whichmaterial.ListStyledraws 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
reviewPanelkeeps 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.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.layout.List+material.Scrollbarin place ofListStyle, and dragging the bar movesPosition.Offsetin 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 indock_review_scroll_test.gopin the thumb's length across uneven cards, the average for unmeasured cards, clamping and the reset rule.-shot: it opens on a session, not the Review tab, and cannot scroll; needs a look in a real window.