parse-git-diff icon indicating copy to clipboard operation
parse-git-diff copied to clipboard

Single line change parse issue with "normal" chunk headers

Open DavisVaughan opened this issue 7 months ago • 0 comments

See https://github.com/parkerbxyz/suggest-changes/issues/50#issuecomment-2833593729

The TLDR is that it seems like parse-git-diff can handle @@ -74,2 +74 @@, but for 1 line changes git will omit the ,1 and just report @@ -74 +74 @@ and that causes the regex handling in parse-git-diff to break.

I see the "normal" chunk regex here: https://github.com/yeonjuan/parse-git-diff/blob/e8ed56df2652b61d4b93a60c39e40fcf6a7d6ced/src/parse-git-diff.ts#L223-L224

Which gets expanded out here: https://github.com/yeonjuan/parse-git-diff/blob/e8ed56df2652b61d4b93a60c39e40fcf6a7d6ced/src/parse-git-diff.ts#L268-L269

I'm no expert here but I think whats happening is that it has an optional capture group for the ,<digit> which should become delLines, but that's missing here so instead the next capture group actually gets put in as delLines, which happens to be addStart, which is 94, so it reports 94 lines in fromFileRange 😢

DavisVaughan avatar Apr 27 '25 19:04 DavisVaughan