-
-
Notifications
You must be signed in to change notification settings - Fork 196
Get list of lines that are common between source and patch #42
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
Comments
The deltas are always differences. But they are ordered and within the Patch instance you have line numbers from source and target. Therefore all line numbers not covered by diffs are equal. |
@wumpz Coming from https://github.com/google/diff-match-patch I also find this very annoying. I'd like the list returned by
Applying these deltas would do nothing, but anything iterating through the list of deltas will have a much easier time figuring out the span of equal regions. |
Let me take a look into this. May be integrate this optioinal? |
I started the first version in 4.7-SNAPSHOT. This is an additional parameter to the diff methods for generating equal parts. I was thinking to do it afterwards, but generating it right within the Patch seemed the cleanest way to do it. |
@cowwoc Could you check if this is what you want? DiffUtils.diff(orig, revised, true) -> last parameter for include equal parts. |
@wumpz No, something is wrong. I am getting back the wrong deltas. I compare:
If I add equals deltas myself, I get back the following deltas: EQUALS: "The" When I use your mechanism, I get: EQUAL: "The dog is " Please double-check this on your end. |
Here is the code I used to add EQUALS after-the-fact:
|
The problem is corrected. Depending on what diff algorithm you use, the list of changes is delivered in a different order. That was the main problem. |
I am trying to iterate through the deltas =, however I would like to get list of lines that are common between the two sets of List by checking
if (delta.getType() == DeltaType.EQUAL) {
}
However I am not able to see how to get this. The JUnit code and test examples do not show this examples. Please help?
The text was updated successfully, but these errors were encountered: