Skip to content

Commit

Permalink
Merge branch 'master' of github.com:knaeckeKami/diffutil.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
knaeckeKami committed Dec 16, 2023
2 parents b5e6777 + 2c88ecc commit b98d4ee
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/src/diffutil_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ class DiffResult<T> {
if (update.posInOwnerList == posInList && update.removal == removal) {
postponedUpdate = update;
postponedUpdates.removeAt(i);
i++;
break;
}
i++;
Expand Down
15 changes: 15 additions & 0 deletions test/diffutil_data_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,21 @@ void main() {
],
);
});

test("github issue #21: move detection bug", () {
final start = [1, 2, 3, 4, 5, 6];
final end = [1, 4, 2, 5, 6, 3];

final updates = diffutil
.calculateListDiff(start, end, detectMoves: true)
.getUpdatesWithData()
.toList();

expect(updates, const [
DataMove(from: 2, to: 5, data: 3),
DataMove(from: 1, to: 2, data: 2),
]);
});
});
}

Expand Down
17 changes: 16 additions & 1 deletion test/diffutil_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void main() {
]);
});

group('test list result calculaction', () {
group('test list result calculation', () {
test('insert works in result list', () {
expect(
diffutil
Expand Down Expand Up @@ -334,6 +334,21 @@ void main() {
);
});
});

test("github issue #21: move detection bug", () {
final start = [1, 2, 3, 4, 5, 6];
final end = [1, 4, 2, 5, 6, 3];

final updates = diffutil
.calculateListDiff(start, end, detectMoves: true)
.getUpdates(batch: false)
.toList();

expect(updates, const [
Move(from: 2, to: 5),
Move(from: 1, to: 2),
]);
});
}

class DataObjectListDiff extends diffutil.ListDiffDelegate<DataObject> {
Expand Down

0 comments on commit b98d4ee

Please sign in to comment.