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

Is it possible to prefer single line changes instead of multi-line? #91

Open
Aaron3 opened this issue Feb 9, 2018 · 2 comments
Open

Comments

@Aaron3
Copy link

Aaron3 commented Feb 9, 2018

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:

image

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}]

@brunoluiz
Copy link

Have you had any luck on doing this with the actual library?

@wcevans
Copy link

wcevans commented Feb 10, 2020

Try using DiffCleanupSemantic. That seems to give the result you are looking for: https://play.golang.org/p/G5QUQZifL-2

DavidGamba added a commit to DavidGamba/dap that referenced this issue Mar 4, 2021
go-diff is not a line by line diffing tool at the moment[1]
Instead, output lines in context.

[1] sergi/go-diff#69
    sergi/go-diff#91

Additionally, add a tab marker '˲   ' to be able to quickly see
whitespace changes.
DavidGamba added a commit to DavidGamba/dap that referenced this issue Mar 4, 2021
go-diff is not a line by line diffing tool at the moment[1]
Instead, output lines in context.

Rename LineByLineDiff to ColorDiff.

Additionally, add a tab marker '˲   ' to be able to quickly see
whitespace changes.

[1] sergi/go-diff#69
    sergi/go-diff#91
DavidGamba added a commit to DavidGamba/dap that referenced this issue Mar 4, 2021
go-diff is not a line by line diffing tool at the moment[1]
Instead, output lines in context.

Rename LineByLineDiff to ColorDiff.

Additionally, add a tab marker '˲   ' to be able to quickly see
whitespace changes.

[1] sergi/go-diff#69
    sergi/go-diff#91
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

3 participants