@@ -120,11 +120,9 @@ func ParseDiffHunkString(diffHunk string) (leftLine, leftHunk, rightLine, rightH
120
120
rightHunk = leftHunk
121
121
}
122
122
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.
126
125
rightLine ++
127
- rightHunk --
128
126
}
129
127
return leftLine , leftHunk , rightLine , rightHunk
130
128
}
@@ -277,6 +275,11 @@ func CutDiffAroundLine(originalDiff io.Reader, line int64, old bool, numbersOfLi
277
275
oldNumOfLines ++
278
276
}
279
277
}
278
+
279
+ // "git diff" outputs "@@ -1 +1,3 @@" for "OLD" => "A\nB\nC"
280
+ // FIXME: GIT-DIFF-CUT-BUG But there is a but 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
+
280
283
// construct the new hunk header
281
284
newHunk [headerLines ] = fmt .Sprintf ("@@ -%d,%d +%d,%d @@" ,
282
285
oldBegin , oldNumOfLines , newBegin , newNumOfLines )
0 commit comments