Update moves when there is another move to exactly the previous move target

This commit is contained in:
Thomas Goyne 2016-03-21 12:47:21 -07:00
parent 0a3158ce74
commit feed7c3479
2 changed files with 12 additions and 1 deletions

View File

@ -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;
}

View File

@ -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") {