Skip to content

feat: add --page-overlap to keep N lines across a page scroll - #313

Merged
umputun merged 2 commits into
masterfrom
feat/page-overlap
Aug 10, 2026
Merged

feat: add --page-overlap to keep N lines across a page scroll#313
umputun merged 2 commits into
masterfrom
feat/page-overlap

Conversation

@umputun

@umputun umputun commented Aug 10, 2026

Copy link
Copy Markdown
Owner

pgdown and pgup advance the diff by a full screen, so the last line you read and the first line of the next screen share no context. --page-overlap N subtracts N from the page motion, carrying the bottom N rows to the top of the next screen.

default is 0, so paging is unchanged for anyone who does not set it. Also available as REVDIFF_PAGE_OVERLAP and page-overlap in the config file.

the whole behavior is a new pageRows() returning max(1, Height - overlap) where the two full-page motions previously passed viewport.Height directly. Everything else is config plumbing and docs.

three scope decisions worth stating:

  • half-page motions are excluded. ctrl+d / ctrl+u already retain half a screen, so subtracting an overlap on top would shrink an already-overlapping motion. Pinned by a test.
  • diff pane only. The file tree, markdown TOC and the two overlay pagers move by entry index rather than visual rows, where a row count has no meaning.
  • a negative value clamps to 0 in NewModel rather than erroring, following --wrap-indent, which is the same shape of flag and clamps in the same place.

the carryover is approximate, not exact, and deviates both ways. Paging stops on cursor positions, and one position can span several rendered rows: a wrapped line or an annotation block at the page edge carries over more than N when the walk rolls back off it, and less than N when the walk takes it whole. In a plain unwrapped diff it is exactly N. This is stated in the pageRows godoc and in the README feature list; the flag description rows stay minimal per the project's flag-description rule.

Related to #311

umputun added 2 commits August 9, 2026 20:28
pgdown and pgup advance the diff by a full screen, so the last line read
and the first line of the next screen share no context. --page-overlap N
subtracts N from the page motion, carrying the bottom N rows of the screen
to the top of the next one. Default 0 keeps current behavior.

the overlap is approximate rather than exact: the walk stops on cursor
positions and one position can span several rendered rows, so a wrapped
line or an annotation block at the page edge carries over more than asked.
Half-page motions do not subtract it, since ctrl+d and ctrl+u already
retain half a screen.

scoped to the diff pane. The tree, TOC and overlay pagers move by entry
index rather than visual rows, where a row count has no meaning.

Related to #311
the pageRows godoc named only the case that carries over more than
requested. The opposite is reachable: worthRollingBack accepts an
oversized first step whatever its height, so a block taller than the
remaining budget is taken whole and carries over less than N, or nothing.

adds a README feature bullet so the approximation is visible to users
setting the flag, not just to readers of the walk. The flag description
rows stay minimal per the project's flag-description rule.
Copilot AI lite review requested due to automatic review settings August 10, 2026 01:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a configurable “page overlap” for full-page diff paging (PgUp/PgDn) so the next screen retains N rows of context from the previous screen, wired through CLI/env/config plus docs and tests.

Changes:

  • Introduce --page-overlap N / REVDIFF_PAGE_OVERLAP / page-overlap config plumbing and documentation.
  • Update diff paging to advance by max(1, viewportHeight - overlap) for PgUp/PgDn (half-page motions unchanged).
  • Add tests covering config parsing, model config propagation, and paging behavior.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
site/docs.html Documents the new --page-overlap option in the website options table.
README.md Adds feature blurb and CLI options table entry for --page-overlap.
plugins/pi/skills/revdiff/SKILL.md Adds examples demonstrating --page-overlap usage in the Pi skill docs.
plugins/codex/skills/revdiff/references/config.md Documents --page-overlap in Codex skill config reference table.
.claude-plugin/skills/revdiff/references/config.md Documents --page-overlap in Claude plugin config reference table.
app/config.go Adds PageOverlap option flag/env/config definition.
app/config_test.go Adds parsing precedence tests (default/flag/env/config/override) for PageOverlap.
app/main.go Wires PageOverlap from parsed options into ui.ModelConfig.
app/ui/model.go Adds pageOverlap mode state and ModelConfig.PageOverlap, clamping negative values.
app/ui/model_test.go Tests NewModel propagation and negative clamping for PageOverlap.
app/ui/diffnav.go Switches PgUp/PgDn to use pageRows() derived from viewport height minus overlap.
app/ui/diffnav_test.go Adds behavioral tests for overlap on PgDn/PgUp and confirms half-page motions ignore overlap.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/ui/diffnav.go
Comment on lines +134 to 136
func (m Model) pageRows() int {
return max(1, m.layout.viewport.Height-m.modes.pageOverlap)
}
Comment thread app/main.go
Comment on lines 214 to 218
NoTree: opts.NoTree,
Wrap: opts.Wrap,
WrapIndent: opts.WrapIndent,
PageOverlap: opts.PageOverlap,
Collapsed: opts.Collapsed,
@umputun
umputun merged commit 995796c into master Aug 10, 2026
6 checks passed
@umputun
umputun deleted the feat/page-overlap branch August 10, 2026 02:04
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.

2 participants