fix: resolve review comment lines with blank snippets#88
Conversation
| if sideLines[j].content == "" { | ||
| continue | ||
| } |
There was a problem hiding this comment.
Potential false positive matching: By skipping blank lines, this function now allows matching across arbitrary gaps of blank lines. If two unrelated code sections happen to share the same normalized content and are separated only by blank lines, they could incorrectly match. Consider adding a sanity check that the gap between start and end is not unreasonably larger than len(targetLines) — for example, ensuring (end - start + 1) <= len(targetLines) * someFactor. Without such a guard, a comment could be attached to the wrong code location in files with many blank lines.
Also, consider adding a unit test for matchConsecutive that directly tests the blank-line-skipping behavior (e.g., sideLines with interspersed empty-content entries), since the existing unit tests only cover strictly consecutive matches.
992d2dc to
5d268ee
Compare
5d268ee to
6000330
Compare
Description
This PR fixes line resolution for review comments when
existing_codecontains internal blank lines.Previously,
splitAndNormalizedropped blank lines from the LLM-provided snippet, but the resolver still required consecutive matches against diff/file lines. As a result, snippets that matched real code with blank lines could fail to resolve to the correctstart_line/end_line.This change updates the matching logic to skip blank lines on the diff/file side as well, while preserving the real start and end line numbers.
Type of Change
How Has This Been Tested?
go test ./internal/diffpasses locallyChecklist