Skip to content

Expand a hunk boundary from the file in diffs and PR files - #294

Merged
jiweiyuan merged 1 commit into
mainfrom
feat/diff-gap-expand
Aug 12, 2026
Merged

Expand a hunk boundary from the file in diffs and PR files#294
jiweiyuan merged 1 commit into
mainfrom
feat/diff-gap-expand

Conversation

@jiweiyuan

Copy link
Copy Markdown
Collaborator

A diff's hunk-boundary band — the row standing in for the lines between two hunks — had no control in its gutter, because a three-line-context patch never carries those lines. git diff run locally asks for the whole file as context, so its gaps were already foldable; GitHub's PR patch is fixed at three lines, and there the band was always inert.

The fold now takes the file's own text and offers exactly what GitHub Desktop offers (its getHunkExpansionType):

  • the file's first hunk reads upward only
  • a gap no longer than one 20-line step opens in a single jump ("Expand All")
  • anything longer offers both ends, stacked in one gutter cell with the downward reveal on top

PR files read their text through contents_url, already pinned to the head — one request per opened file, no git fetch and no checkout, matching how the Files tab already renders. When the read is unavailable (binary, too large, no access) the band stays inert, the way GitHub Desktop draws a gap it cannot expand.

The gutter's paired controls are now stacked rather than side by side, following the same source.

Unit tests cover the three-state rule and the splice (line numbers on both sides, and the band keeping what is still hidden). swift build clean, 245 tests pass. The drawing itself is unverified on screen — screen capture is unavailable in this environment.

Release Notes: Expand the context around a hunk in the diff and PR views — the gutter's reveal controls now open the lines between hunks, not just folded runs.

A three-line-context patch never carries the lines around its hunks, so the
band standing in for that gap had no control at all. The fold now takes the
file's own text and offers what GitHub Desktop offers: the first hunk reads
upward only, a gap within one 20-line step opens at once, and a longer one
gets both ends — stacked in the gutter cell, downward reveal on top. PR files
read their text through `contents_url` at the head, one request per opened
file, so nothing needs fetching or checking out; without it the band stays
inert, the way GitHub Desktop draws a gap it cannot expand.
@jiweiyuan
jiweiyuan merged commit f6a3b9c into main Aug 12, 2026
4 of 5 checks passed
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
landing Building Building Preview Aug 12, 2026 10:37pm

Request Review

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