-
Notifications
You must be signed in to change notification settings - Fork 402
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
🐛 Sub-optimal diff highlighting in a simple change #246
Comments
Responding to @dandavison's comment in #245:
I would prefer the diff parsing algorithm to be kept orthogonal to the display style. |
I just came across a similar issue, where diff-highlight's algorithm produces a better output than delta's: There is indeed, in semantic terms, no shared content between the two larger hunks, so diff-highlight is "right"* to not highlight any content in them; but to be fair, markup characters and whitespace are shared between the hunks, by the very nature of HTML. Maybe delta's algorithm could try to ignore such markup characters (and maybe whitespace) when calculating the similarity between two blocks? * Not by its merits, but for the same reason a stopped clock is right twice a day — it just doesn't try to match differently-sized hunks. |
Adding a separate issue for the topic originally mentioned at #245:
Here's the delta output (notice the within-line highlights of removed/added text):
And here's what diff-so-fancy/diff-highlight shows (not the best possible result, but a better default):
Finally, here's delta with
--word-diff-regex = .
, which is the most accurate highlighting:I'd expect delta to provide better highlighting by default — not necessarily the best possible result shown above; doing the same as diff-highlight would have been satisfactory.
The text was updated successfully, but these errors were encountered: