Repository navigation
fix(ui): bound page scroll so paging cannot skip unrendered rows - #312
Merged
Merged
Conversation
moveDiffCursorDownBy/UpBy walked the cursor until its visual delta reached rows, then scrolled the viewport by that actual delta. One cursor step can span many rows through hunkLineHeight (wrap continuations, annotation blocks), so a tall line at the page boundary advanced the viewport further than a page and skipped rows that were never displayed. both walks now undo the step that carries the delta past rows, restoring diffCursor and cursorOnAnnotation and breaking immediately. The first step stays exempt so a line taller than the whole viewport remains reachable, which still scrolls by its full height.
…oved the rollback fired whenever any step had been taken, so a block taller than the page ahead of the cursor collapsed pgdown to a one-row scroll: the annotation flip consumed one row, the next step overshot, and the walk rolled back to that single row. The screen looked unchanged and the following press took the same oversized step anyway. worthRollingBack requires half a page of walked budget before undoing a step. A block with no selectable position inside it is now stepped over in one press as before, while an ordinary tall line at the page boundary still rolls back. adds the up-direction case, which had no test - the previous pgup assertion was satisfied by construction and held with the rollback deleted - and corrects the down-walk comment, which named the line stepped onto when the height comes from the line stepped off.
There was a problem hiding this comment.
Pull request overview
Fixes diff-pane paging so PgDown/PgUp can’t advance the viewport by more than the requested page size when a single cursor step spans many rendered rows (wrap continuations / multi-line annotation blocks), preventing “skipped” rows that were never rendered.
Changes:
- Bound the cursor-walk paging logic to roll back the overshooting step (when it’s worthwhile) and then scroll by the actual walked delta.
- Added targeted regression tests for down/up overshoot and the “don’t collapse to near-zero scroll” case with blocks taller than a page.
- Documented the paging walk/rollback behavior in the gotchas notes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/ui/diffnav.go | Adds overshoot rollback + worthRollingBack gating to keep paging within a page when encountering tall rendered lines. |
| app/ui/diffnav_test.go | Adds regression tests ensuring paging doesn’t skip unseen rows and still progresses past content taller than the viewport. |
| .claude/rules/gotchas.md | Updates internal gotchas documentation to reflect the new paging/rollback behavior and its limits. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+224
to
+225
| // anyway - worse than simply taking it now. half a page is the bar, matching ctrl+d/ctrl+u. | ||
| // a first step always passes (walked is 0), so the walk can never refuse to move. |
worthRollingBack returns false for walked == 0, so 'a first step always passes' read as 'returns true' directly above the return statement. State the mechanism instead.
Deploying revdiff with
|
| Latest commit: |
a4cda26
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c0b1960d.revdiff.pages.dev |
| Branch Preview URL: | https://fix-pagedown-overshoot.revdiff.pages.dev |
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.
page down could scroll the viewport further than one page and skip rows that were never rendered.
moveDiffCursorDownBy/moveDiffCursorUpBywalk the cursor until its visual delta reachesrows, then scroll the viewport by that actual delta. One cursor step can span many rows throughhunkLineHeight(wrap continuations, annotation blocks), so a tall line sitting at the page boundary made the walk overshoot: with a 5-row annotation there, the viewport advanced up to 4 rows past a full page and the tail of that annotation was scrolled past without ever being displayed. Recoverable with pgup, but nothing bounded the shift and no test caught it.both walks now undo the step that carries the delta past
rows, restoringdiffCursorandcursorOnAnnotation(the only two fields the move helpers mutate) and breaking immediately.the rollback is gated on
worthRollingBack- half a page of walked budget - rather than on having moved at all. That gate matters: a block taller than the page has no selectable cursor position inside it, so rolling back to the row or two walked before it scrolls the pane by almost nothing and the next press takes the same oversized step anyway. Gating on "has moved" produced exactly that one-row collapse.known limit, recorded in
.claude/rules/gotchas.md: a single step taller than the whole page still scrolls by its full height and still skips. There is no cursor position inside such a block, so "don't skip", "cursor stays visible" and "cursor sits on a selectable line" cannot all hold. Master behaves the same way; this does not make it worse. It is also why pgdown then pgup is only exactly reversible for uniform-height content.three tests, each verified to fail when the branch it covers is removed: the down-direction bound, the up-direction bound (previously untested - the old pgup assertion was satisfied by construction), and the no-collapse case.