delta icon indicating copy to clipboard operation
delta copied to clipboard

Incomplete diff.🐛

Open k4leg opened this issue 3 years ago • 2 comments

Delta 0.11.3. File a.lua, b.lua. See, first part is missing:

1

UPD: diff is alias for diff --color -Naurp0.

k4leg avatar Feb 14 '22 20:02 k4leg

Thanks for the report and the test files @k4leg -- I see the same bug as you.

Incidentally, using delta a.lua b.lua does work on your files (under the hood this uses git diff --no-index instead of diff -u). But that doesn't change the fact that this is a bug with delta's handling of diff -u.

dandavison avatar Feb 14 '22 21:02 dandavison

I assume it works with the git diff command because delta is requesting color? (Since that would prefix the "---" line by a color escape sequence.)

So, it looks like delta needs to start to interpret the counts on the "@@" lines so that it can ignore a "--- " prefix if it is in the middle of a hunk. One possibility is to stash off the @@ line and only interpret it if you run into a "--- " line before seeing a "diff " line (at which point the code would do some quick length calculations and see if it is in the hunk or not).

This is one of my big regrets looking back at when I invented unified diffs: I should have made the filename headers "@- file" and "@+ file" so that there could no confusion possible between a header line and a change line. Oh well.

WayneD avatar Mar 07 '22 18:03 WayneD