Change writeFixedFile to replace the right line-range.

The function assumed, previously, that issue.Line always equals
issue.LineRange.From.  But this needn't be true, and the code needn't
assume it.  Now we actually replace the specified line-range.
This commit is contained in:
Craig Silverstein 2020-01-21 14:56:27 -08:00
parent 45f1e48f3d
commit 06d26d5c12

View File

@ -218,7 +218,7 @@ func (f Fixer) writeFixedFile(origFileLines [][]byte, issues []result.Issue, tmp
} }
origFileLineNumber := i + 1 origFileLineNumber := i + 1
if nextIssue == nil || origFileLineNumber != nextIssue.Line() { if nextIssue == nil || origFileLineNumber != nextIssue.GetLineRange().From {
outLine = string(origFileLines[i]) outLine = string(origFileLines[i])
} else { } else {
nextIssueIndex++ nextIssueIndex++