dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.43k stars 361 forks source link

🐛 Can't reproduce diff-highlight output in delta #1552

Closed snoopy closed 8 months ago

snoopy commented 9 months ago

I'm trying delta as a replacement for diff-highlight but there seems to be a difference in how certain changes are highlighted. I can't reproduce this behavior in delta.

In this image the delta diff output is shown on the top and diff-highlight on the bottom. diff

Note how diff-highlight correctly highlights the change while delta does not. This happens regardless of using --diff-highlight. I also tried changing the value of max-line-distance but to no avail.

Is this just a user error or actually a bug?

dandavison commented 8 months ago

Hi @snoopy, try something like word-diff-regex = .. delta first tokenizes the input by "word", and then diffs the token stream. word-diff-regex is the tokenization regex defining what a "word" is.

      --word-diff-regex <REGEX>
          Regular expression defining a 'word' in within-line diff algorithm.

          The regular expression used to decide what a word is for the within-line highlight algorithm. For less fine-grained matching than the default try --word-diff-regex="\S+" --max-line-distance=1.0 (this is m
ore similar to `git --word-diff`).

          [default: \w+]
dandavison commented 8 months ago

delta doesn't provide an emulation of diff-highlight's word diff algorithm, but I've always thought it would be interesting/useful to add it. If anyone wanted to add a word-diff-algorithm flag to delta allowing user's to choose between delta's current algorithm, and a Rust implementation of diff-highlight's (simple) algorithm, etc, I think that could be good.