Skip to content

Fix diffAcceptRejectHunk with partial FileDiffMetadata#428

Merged
amadeus merged 1 commit intomainfrom
amadeus/resolve-partial-patch
Mar 26, 2026
Merged

Fix diffAcceptRejectHunk with partial FileDiffMetadata#428
amadeus merged 1 commit intomainfrom
amadeus/resolve-partial-patch

Conversation

@amadeus
Copy link
Copy Markdown
Member

@amadeus amadeus commented Mar 26, 2026

There was a regression when I refactored the patch resolving architecture, where i didn't account for FileDiffMetadata that was isPartial = true.

Fixed the issue and added a test to ensure we don't regress.

Fixes #427

@amadeus amadeus requested a review from Copilot March 26, 2026 18:46
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

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

Project Deployment Actions Updated (UTC)
pierrejs-diff-demo Ready Ready Preview Mar 26, 2026 6:46pm
pierrejs-docs Ready Ready Preview Mar 26, 2026 6:46pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a regression in @pierre/diffs where diffAcceptRejectHunk could throw when operating on FileDiffMetadata parsed from patch files (isPartial = true) that contain omitted context tracked via collapsedBefore.

Changes:

  • Update resolveRegion to avoid materializing collapsed context lines when diff.isPartial is true, while still advancing virtual cursor metrics correctly.
  • Add a regression test ensuring accepting a hunk from a partial patch works without requiring the omitted context lines.

Reviewed changes

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

File Description
packages/diffs/src/utils/resolveRegion.ts Skips pushing collapsed context lines for partial diffs and introduces a helper to keep cursor/metrics consistent.
packages/diffs/test/diffAcceptRejectHunk.test.ts Adds coverage for accepting hunks on parsePatchFiles-produced (partial) diffs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@amadeus amadeus merged commit a312122 into main Mar 26, 2026
12 checks passed
@amadeus amadeus deleted the amadeus/resolve-partial-patch branch March 26, 2026 23:13
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.

Bug: diffAcceptRejectHunk throws on FileDiffMetadata from patch

2 participants