@@ -120,11 +120,9 @@ func ParseDiffHunkString(diffHunk string) (leftLine, leftHunk, rightLine, rightH
120120 rightHunk = leftHunk
121121 }
122122 if rightLine == 0 {
123- // "git diff" outputs 2 different formats for the same change "OLD" => "A\nB\nC"
124- // * "@@ -1 +1,3 @@": the expected result
125- // * "@@ -1,1 +0,4 @@": the "0" means "insert before the first line"
123+ // FIXME: GIT-DIFF-CUT-BUG search this tag to see details
124+ // this is only a hacky patch, the rightLine&rightHunk might still be incorrect in some cases.
126125 rightLine ++
127- rightHunk --
128126 }
129127 return leftLine , leftHunk , rightLine , rightHunk
130128}
@@ -277,6 +275,11 @@ func CutDiffAroundLine(originalDiff io.Reader, line int64, old bool, numbersOfLi
277275 oldNumOfLines ++
278276 }
279277 }
278+
279+ // "git diff" outputs "@@ -1 +1,3 @@" for "OLD" => "A\nB\nC"
280+ // FIXME: GIT-DIFF-CUT-BUG But there is a bug in CutDiffAroundLine, then the "Patch" stored in the comment model becomes "@@ -1,1 +0,4 @@"
281+ // It may generate incorrect results for difference cases, for example: delete 2 line add 1 line, delete 2 line add 2 line etc, need to double check.
282+
280283 // construct the new hunk header
281284 newHunk [headerLines ] = fmt .Sprintf ("@@ -%d,%d +%d,%d @@" ,
282285 oldBegin , oldNumOfLines , newBegin , newNumOfLines )
0 commit comments