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

Not optimal number of diffs #3

Open
vmakhaev opened this issue Mar 6, 2016 · 1 comment
Open

Not optimal number of diffs #3

vmakhaev opened this issue Mar 6, 2016 · 1 comment

Comments

@vmakhaev
Copy link

vmakhaev commented Mar 6, 2016

I suppose this happens because array has repeating elements.
Here is test case: https://github.com/vmakhaev/arraydiff-testcase
As you see, I remove one item and expect only one RemoveDiff, but get:

[ RemoveDiff { index: 86, howMany: 1 },
  MoveDiff { from: 21, to: 20, howMany: 5 },
  MoveDiff { from: 27, to: 26, howMany: 6 },
  MoveDiff { from: 34, to: 33, howMany: 6 },
  MoveDiff { from: 41, to: 40, howMany: 6 },
  MoveDiff { from: 48, to: 47, howMany: 5 },
  MoveDiff { from: 54, to: 53, howMany: 6 },
  MoveDiff { from: 61, to: 60, howMany: 7 },
  MoveDiff { from: 70, to: 68, howMany: 8 },
  MoveDiff { from: 79, to: 68, howMany: 1 },
  MoveDiff { from: 80, to: 79, howMany: 6 } ]
@rkstedman
Copy link
Contributor

This jsondiffpatch library seems to handle that case correctly (example)

I haven't been able to look and see what the implementation difference is but maybe we can learn from it and update the arraydiff implementation.
https://github.com/benjamine/jsondiffpatch/blob/master/docs/arrays.md

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

2 participants