Skip to content

fix(patch): match canonically equivalent unicode#32795

Draft
cyq1017 wants to merge 1 commit into
anomalyco:devfrom
cyq1017:codex/opencode-31651-apply-patch-nfc
Draft

fix(patch): match canonically equivalent unicode#32795
cyq1017 wants to merge 1 commit into
anomalyco:devfrom
cyq1017:codex/opencode-31651-apply-patch-nfc

Conversation

@cyq1017

@cyq1017 cyq1017 commented Jun 18, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #31651

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

apply_patch could fail to match a file line when the file stores the text in NFD form and the patch old line uses NFC form. The text is canonically equivalent, but the existing match passes only handled exact text, whitespace differences, and punctuation normalization.

This adds a final seekSequence pass that compares trimmed lines after NFC normalization. Existing match priority stays the same; the new pass only handles Unicode canonical equivalence after the stricter passes fail.

How did you verify your code works?

  • bun test test/tool/apply_patch.test.ts -t "matches with canonically equivalent Unicode text"
  • bun test test/tool/apply_patch.test.ts
  • bun test test/patch/patch.test.ts
  • prettier --check packages/opencode/src/patch/index.ts packages/opencode/test/tool/apply_patch.test.ts
  • git diff --check HEAD~1..HEAD

Screenshots / recordings

Not applicable.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Signed-off-by: cyq <15000851237@163.com>
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

Why it's related: Both PRs address the same issue (#31651) of matching canonically equivalent Unicode text in patch application. PR #31847 appears to be an earlier attempt at fixing this problem with NFC/NFD normalization. You may want to check if #31847 is already merged or closed, and consolidate work if needed.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

apply_patch verification fails on canonically-equivalent Unicode — seekSequence needs an NFC pass

1 participant