Open Aaron3 opened 6 years ago
When diffing JSON, we have some json like:
{ "del": "^2.2.0", "es6-symbol": "^3.1.1", "eslint": "^4.11.0", "eslint-config-enough": "0.2.5", }
If we compare to
{ "del": "^2.2.0", "eslint": "^4.11.0", "eslint-config-enough": "0.2.5", }
We end up with:
It would be nice to be able to prefer full-line or full word changes instead of single-character changes.
If you change the word "hello" to "goodbye", you see the diff as:
[{Delete hell} {Insert g} {Equal o} {Insert odbye}]
Which is much harder for a human to read than if the lib had the ability to prefer word/line boundaries and showed: [{Delete hello} {Insert goodbye}]
[{Delete hello} {Insert goodbye}]
Have you had any luck on doing this with the actual library?
Try using DiffCleanupSemantic. That seems to give the result you are looking for: https://play.golang.org/p/G5QUQZifL-2
DiffCleanupSemantic
When diffing JSON, we have some json like:
If we compare to
We end up with:
It would be nice to be able to prefer full-line or full word changes instead of single-character changes.
If you change the word "hello" to "goodbye", you see the diff as:
[{Delete hell} {Insert g} {Equal o} {Insert odbye}]
Which is much harder for a human to read than if the lib had the ability to prefer word/line boundaries and showed:
[{Delete hello} {Insert goodbye}]