Update moves when there is another move to exactly the previous move target
This commit is contained in:
parent
0a3158ce74
commit
feed7c3479
|
@ -226,7 +226,7 @@ void CollectionChangeBuilder::move(size_t from, size_t to)
|
|||
// to the other
|
||||
if (move.to >= to && move.to < from)
|
||||
++move.to;
|
||||
else if (move.to < to && move.to > from)
|
||||
else if (move.to <= to && move.to > from)
|
||||
--move.to;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -284,6 +284,17 @@ TEST_CASE("[collection_change] move()") {
|
|||
c.move(6, 12);
|
||||
REQUIRE_INDICES(c.modifications, 9);
|
||||
}
|
||||
|
||||
SECTION("bumps previous moves to the same location") {
|
||||
c.move(5, 10);
|
||||
c.move(7, 10);
|
||||
REQUIRE_MOVES(c, {5, 9}, {8, 10});
|
||||
|
||||
c = {};
|
||||
c.move(5, 10);
|
||||
c.move(15, 10);
|
||||
REQUIRE_MOVES(c, {5, 11}, {15, 10});
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("[collection_change] calculate() unsorted") {
|
||||
|
|
Loading…
Reference in New Issue