Repository navigation
fix(diff): retry new-side hunk match without blank lines - #1777
Merged
lizhengfeng101 merged 2 commits intoNov 3, 2026
Merged
Conversation
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
kall
added a commit
to kall/open-code-review
that referenced
this pull request
Nov 3, 2026
No text conflicts and no silent breaks. Upstream added no new calls to the helpers the branch moved into internal/model and left the filter algorithms untouched. The internal/diff fixes reach the core commands through the shared code: `ocr core relocate` calls diff.ResolveComment, so it gains the blank-line-free new-side retry (alibaba#1777), and `ocr core diff` goes through GetDiff, so it keeps tracked gitignored files in workspace mode (alibaba#1837) and splits bare "diff --git" headers (alibaba#1691). New file types (.jsonc, HAML/Slim/ERB, EJS/Liquid/Nunjucks) and Scala rules are shared rule data. The branch delta against v1.13.5 is unchanged. Build, vet, make check and the full -race test suite pass; coverage is 91.2%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A comment's line numbers come from matching its
existing_codesnippet against the diff hunks, falling back to the full new file.splitAndNormalizedrops blank lines from the snippet, butextractSideLineskeeps them in the hunk, so when the quoted code spans a blank line, the match on the hunk's new side misses the quoted location. The full file match returns the first occurrence, so if the same code appears earlier in the file, the comment is located there.Fix: when the new side does not match line by line,
resolveFromHunkmatches it again without its blank lines, and a hit's line range includes the blank lines in between; only if that also misses does it match the old side.Type of Change
How Has This Been Tested?
internal/diff/resolver_test.goadds the table testTestResolveFromHunk_BlankLineRetry, including:An added block spanning a blank line:
maingives 2..5, expected 8..11.Code moved into another function with a blank line inserted:
maingives 2..3, expected 9..11.make testpasses locallyManual testing (describe below)
Checklist
go fmt,go vet)AI/LLM disclosure, Claude Code (Claude Opus 5.5) was used to investigate the failure, prepare the changes, and draft this PR.