knaeckeKami / diffutil.dart

Apache License 2.0
27 stars 4 forks source link

Removing 2 consecutive elements from a list returns incorrect updates #15

Closed mikkomultanen closed 1 year ago

mikkomultanen commented 1 year ago
    expect(
      calculateListDiff([1, 0, 2, 0, 3], [1, 0, 3], detectMoves: false).getUpdates().toList(),
      [const Remove(position: 2, count: 2)],
    );

Expected: [Remove:Remove{position: 2, count: 2}] Actual: [Remove:Remove{position: 3, count: 1}, Remove:Remove{position: 1, count: 1}]

knaeckeKami commented 1 year ago

Thank you for the bug report!

It think I re-implemented a bug from the Android source code when porting. https://issuetracker.google.com/issues/123376278

If this is the issue, it is related to duplicated items in a list.

Will try to fix it, unfortunately it looks like the fix was to essentially re-implement to algorithm from scratch.

https://android-review.googlesource.com/c/platform/frameworks/support/+/1253271