mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-24 13:31:29 +00:00
Fix handling of move_last_over() on the second-to-last row
This commit is contained in:
parent
47cee90d32
commit
1289c4806c
@ -263,7 +263,7 @@ void CollectionChangeBuilder::move(size_t from, size_t to)
|
||||
void CollectionChangeBuilder::move_over(size_t row_ndx, size_t last_row)
|
||||
{
|
||||
REALM_ASSERT(row_ndx <= last_row);
|
||||
if (row_ndx == last_row) {
|
||||
if (row_ndx == last_row || row_ndx + 1 == last_row) {
|
||||
erase(row_ndx);
|
||||
return;
|
||||
}
|
||||
|
@ -126,6 +126,17 @@ TEST_CASE("[collection_change] move_over()") {
|
||||
REQUIRE(c.moves.empty());
|
||||
}
|
||||
|
||||
SECTION("is just erase when row + 1 == last_row") {
|
||||
c.move_over(0, 6);
|
||||
c.move_over(4, 5);
|
||||
c.move_over(0, 4);
|
||||
c.move_over(2, 3);
|
||||
|
||||
REQUIRE_INDICES(c.deletions, 0, 2, 4, 5, 6);
|
||||
REQUIRE_INDICES(c.insertions, 0);
|
||||
REQUIRE_MOVES(c, {5, 0});
|
||||
}
|
||||
|
||||
SECTION("marks the old last row as moved") {
|
||||
c.move_over(5, 8);
|
||||
REQUIRE_MOVES(c, {8, 5});
|
||||
|
Loading…
x
Reference in New Issue
Block a user