Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 improve diff -u comparison #229

Closed
MarcoIeni opened this issue Jun 28, 2020 · 3 comments
Closed

🚀 improve diff -u comparison #229

MarcoIeni opened this issue Jun 28, 2020 · 3 comments

Comments

@MarcoIeni
Copy link
Contributor

I am comparing this project with diff-so-fancy with the diff -u usage.
I want to see the difference between two files named one and two:

image

As you can see diff-so-fancy highlights the different word on the first line.
Why delta doesn't do it?

@dandavison
Copy link
Owner

Hi @MarcoIeni, In the current version of delta, you can make it do it by bumping the max-line-distance parameter (see #140 for explanation):

image

I'm about to release a new version of delta which will highlight this by default (master branch):

image

Incidentally, in the new version you will be able to use delta one two as a wrapper for diff -u one two | delta:

image

@MarcoIeni
Copy link
Contributor Author

Awesome, thanks!

@dandavison
Copy link
Owner

What #140 comes down to is that delta (unlike diff-highlight, diff-so-fancy, GitHub, GitLab, etc) does not assume that a pair of lines are homologous and should be highlighted as if one has evolved from the other. The reason for this is that delta (unlike the others), when confronted with a hunk containing different numbers of - and + lines, attempts to infer which lines "match" each other. So, it has to have a criterion. And the default value of the parameter defining that criterion was set a bit too conservatively in the released version. There's room for improvement/expansion of the options delta offers regarding edit inference algorithms. For example, the simple-minded algorithm implemented by diff-highlight (which diff-so-fancy uses as a library) could be added to delta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants