Skip to content

fix(chat): mark the lines a diff leaves out between hunks - #1304

Merged
agegr merged 1 commit into
mainfrom
fix/issue-1297-diff-hunk-gaps
Oct 18, 2026
Merged

agegr merged 1 commit into
mainfrom
fix/issue-1297-diff-hunk-gaps

Conversation

@agegr

@agegr agegr commented Oct 16, 2026

Copy link
Copy Markdown
Owner

The split diff in chat (edit tool's details.patch, apply_patch) and the
git diff view in the file panel dropped every @@ header, so two hunks
rendered as if their lines were adjacent in the file.

parseUnifiedPatch() now emits a gap row between two hunks of one file
when the second header starts past where the first one ends, with the
skipped count (headers with an empty side, as in --unified=0, count
from the line they name). Contiguous hunks and the start of a file get
no row. The apply_patch V4A input has no line numbers, so a later @@
chunk gets a gap without a count. Both diff views render it as a dim
"⋯ N unchanged lines" row; the file panel merges it into its existing
collapsed-lines marker, now translated. The demo copies get the same
change.

Fixes #1297

Testing

  • node --experimental-strip-types --test lib/patch.test.mjs lib/apply-patch.test.mjs (gap counts incl. omitted counts, --unified=0 empty sides, new/deleted files, multi-file patches, contiguous hunks, V4A chunks)
  • Integrated with the other fix branches of this batch on main b017cd4: tsc --noEmit clean, npm test 2787 pass / 0 fail / 1 skipped.
  • Not checked in a browser.

🤖 Generated with Claude Code

The split diff in chat (edit tool's details.patch, apply_patch) and the
git diff view in the file panel dropped every @@ header, so two hunks
rendered as if their lines were adjacent in the file.

parseUnifiedPatch() now emits a gap row between two hunks of one file
when the second header starts past where the first one ends, with the
skipped count (headers with an empty side, as in --unified=0, count
from the line they name). Contiguous hunks and the start of a file get
no row. The apply_patch V4A input has no line numbers, so a later @@
chunk gets a gap without a count. Both diff views render it as a dim
"⋯ N unchanged lines" row; the file panel merges it into its existing
collapsed-lines marker, now translated. The demo copies get the same
change.

Fixes #1297

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@agegr
agegr merged commit 246c1f2 into main Oct 18, 2026
4 checks passed
agegr added a commit to brynne8/pi-web that referenced this pull request Oct 19, 2026
Resolves the conflicts with agegr#1304's hunk-gap rows: unifiedDiffLines()
passes a file's gap rows through, so the file viewer's diff keeps its
"N unchanged lines" markers and the one-column card draws them too, with
the same row the two-column view uses (DiffGapRow).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@agegr
agegr deleted the fix/issue-1297-diff-hunk-gaps branch October 29, 2026 13:01
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
The split diff in chat (edit tool's details.patch, apply_patch) and the
git diff view in the file panel dropped every @@ header, so two hunks
rendered as if their lines were adjacent in the file.

parseUnifiedPatch() now emits a gap row between two hunks of one file
when the second header starts past where the first one ends, with the
skipped count (headers with an empty side, as in --unified=0, count
from the line they name). Contiguous hunks and the start of a file get
no row. The apply_patch V4A input has no line numbers, so a later @@
chunk gets a gap without a count. Both diff views render it as a dim
"⋯ N unchanged lines" row; the file panel merges it into its existing
collapsed-lines marker, now translated. The demo copies get the same
change.

Fixes agegr#1297

Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
The split diff in chat (edit tool's details.patch, apply_patch) and the
git diff view in the file panel dropped every @@ header, so two hunks
rendered as if their lines were adjacent in the file.

parseUnifiedPatch() now emits a gap row between two hunks of one file
when the second header starts past where the first one ends, with the
skipped count (headers with an empty side, as in --unified=0, count
from the line they name). Contiguous hunks and the start of a file get
no row. The apply_patch V4A input has no line numbers, so a later @@
chunk gets a gap without a count. Both diff views render it as a dim
"⋯ N unchanged lines" row; the file panel merges it into its existing
collapsed-lines marker, now translated. The demo copies get the same
change.

Fixes agegr#1297

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Edit diff 的不同 hunk 之间缺少省略提示

1 participant