Closed waldyrious closed 4 years ago
There's also the sub-optimal detection of the changed text, by the way. Should I open a separate issue for that?
For reference, diff-so-fancy/diff-highlight shows a much more sensible result:
Hey @waldyrious, thanks.
There's also the sub-optimal detection of the changed text, by the way. Should I open a separate issue for that?
Yes please. FWIW, with word-diff-regex = .
delta gives better highlighting than diff-highlight:
The algorithm in diff-highlight/diff-so-fancy is described thus:
It will find the common prefix and suffix of two lines, and consider everything in the middle to be "different".
In contrast, delta's algorithm is to tokenize into "words" defined by the customizable regex (word-diff-regex
), and then run a Levenshtein-type dynamic programming edit inference algorithm at the level of "words" (I think this is more properly known as Wagner-Fischer or Needleman-Wunsch).
I've been thinking that it will probably make sense to implement the (deliberately) more simple-minded algorithm of diff-highlight as an alternative diff-highlighting algorithm in delta. Do you think diff-highlight
and diff-so-fancy
in delta should default to using the original, simpler, diff highlight algorithm? On the one hand there is something appealing in being able to say that delta --diff-highlight
aims for a pixel-for-pixel emulation, and OTOH I do find that the dynamic programming algorithm often gives more helpful results.
For https://github.com/Homebrew/homebrew-cask-fonts/pull/2188, I renamed a file and also edited it. Here's how delta shows the diff (with
diff-highlight
emulation and a couple extra customizations, which should only influence style, not semantics):And for comparison, here's how git shows it natively (without using a pager):
I would like delta to not show the renamed header twice.