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

🐛 Duplicate "renamed" header when file is renamed with changes #245

Closed
waldyrious opened this issue Jul 11, 2020 · 2 comments
Closed

Comments

@waldyrious
Copy link
Contributor

For Homebrew/homebrew-cask-fonts#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):

Screenshot 2020-07-11 at 22 37 38

And for comparison, here's how git shows it natively (without using a pager):

Screenshot 2020-07-11 at 22 37 39

I would like delta to not show the renamed header twice.

@waldyrious
Copy link
Contributor Author

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:

Screenshot 2020-07-11 at 23 22 41

@dandavison
Copy link
Owner

dandavison commented Jul 11, 2020

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:

image

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-highlightaims for a pixel-for-pixel emulation, and OTOH I do find that the dynamic programming algorithm often gives more helpful results.

@dandavison dandavison changed the title 🐛 Duplicate "renamed" header 🐛 Duplicate "renamed" header when file is renamed with changes Aug 2, 2020
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