Skip to content
New issue

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

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

Already on GitHub? # to your account

🐛Missing word highlighting #198

Closed
fgsch opened this issue May 19, 2020 · 1 comment
Closed

🐛Missing word highlighting #198

fgsch opened this issue May 19, 2020 · 1 comment

Comments

@fgsch
Copy link

fgsch commented May 19, 2020

delta version: built from master @ bbbd722
diff -u:

--- a       2020-05-20 00:25:50.000000000 +0100
+++ b      2020-05-20 00:24:00.000000000 +0100
@@ -1,5 +1,5 @@
 {
   "foo": {
-    "bar": "foo,baz_qux,bar"
+    "bar": "foo,bar"
   }
 }

delta: baz_qux is not highlighted

With --max-line-distance=0.4 the word is highlighted as expected.

This might be a duplicate of #184 so feel free to close it.

@dandavison
Copy link
Owner

Yes, the calculation it is doing is:

  • baz_qux, is 8 characters
  • "bar": "foo,baz_qux,bar" is 24 characters
  • So under the hypothesis that those two lines are a genuine match, then 1/3 of the characters have been changed in an edit operation.
  • So if we set --max-line-distance below 1/3, Delta says: those are too different, I'm not convinced that's a genuine matching pair of lines.
  • But if we set it to, say, 0.333334 then it accepts them as a genuine homologous pair.

Discussion of how we might develop delta's line-matching algorithms is in #140, which also describes an experimental environment variable which can be used to convince delta to always match lines naively when there are the same number of plus and minus lines (that's what other tools such as diff-highlight, diff-so-fancy, github, do). I'll close this and we can discuss there, but further thoughts/opinions/ideas are really welcome here. I think it's an area that benefits from multiple people being involved, not least as we all use different languages with different syntax characteristics.

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

No branches or pull requests

2 participants