Skip to content

DiffRowGenerator returns too many diffs in special cases #65

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

Closed
ghost opened this issue Jan 13, 2020 · 5 comments
Closed

DiffRowGenerator returns too many diffs in special cases #65

ghost opened this issue Jan 13, 2020 · 5 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Jan 13, 2020

Describe the bug
DiffRowGenerator returns too many diffs in special cases.

To Reproduce
Steps to reproduce the behavior:

 DiffRowGenerator generator = DiffRowGenerator.create()
                .showInlineDiffs(true)
                .reportLinesUnchanged(true)
                .oldTag(f -> "~")
                .newTag(f -> "**")
                .mergeOriginalRevised(true)
//                .inlineDiffByWord(true)
                .build();

        List<DiffRow> diffRows = generator.generateDiffRows(sortedRemovals, sortedAdditions);

sortedRemovals:
["Ich möchte nicht mit einem Bot sprechen.", "Ich soll das schon wieder wiederholen?"]

sortedAdditions:
["Ich möchte nicht mehr mit dir sprechen. Leite mich weiter.", "Kannst du mich zum Kundendienst weiterleiten?"]

Expected behavior
diffRows should have size 2 but it has size 3.

System

  • Java version 1.8
  • Version 4.5

Setting inlineDiffByWord(true) does not produce the error.

@wumpz
Copy link
Collaborator

wumpz commented Feb 23, 2020

You are diffing sortedRemovals and sortedAdditons? How do you know, that there should be 2 diffs?

@ghost
Copy link
Author

ghost commented Apr 27, 2020

Well it should diff the 2 pairs hence it should return 2 DiffRows but it returns 3 instead :/

@wumpz
Copy link
Collaborator

wumpz commented Apr 28, 2020

Sorry missread diffrows as diffs. You are right, that the rowcount should be the same, but there could be multiple diff in one line. That was my fault.

However now I can reproduce your problem.

@wumpz wumpz pinned this issue Apr 28, 2020
@wumpz wumpz self-assigned this Apr 28, 2020
@wumpz wumpz added the bug label Apr 28, 2020
@wumpz
Copy link
Collaborator

wumpz commented May 7, 2020

After digging into this I find it I am not yet quit sure how to solve this. The diff result is correct. The problem is, that something without linefeed is replaced by something with linefeed and the linefeed that remains is replaced by another delta.

@wumpz wumpz closed this as completed in a8e4ce2 May 17, 2020
@wumpz
Copy link
Collaborator

wumpz commented May 17, 2020

So here is the first try to at least optionally try to fix this.

There is a new method in the builder (replaceOriginalLinefeedInChangesWithSpaces) to switch this on.
As you already found out, this happens only occasionally in this case I already mentioned.

So could you give it a try?

@wumpz wumpz unpinned this issue May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant