From 285dc79a6bc67d367b2ecf766111d9635ee21520 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Wed, 30 Mar 2022 10:07:55 +0200 Subject: [PATCH] fix edge case when moving backwards from move operation --- src/utils/ListIterator.js | 6 +++++- tests/y-array.tests.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/ListIterator.js b/src/utils/ListIterator.js index 35d54324..d7601c1b 100644 --- a/src/utils/ListIterator.js +++ b/src/utils/ListIterator.js @@ -199,7 +199,11 @@ export class ListIterator { return this } let item = this.nextItem - len += ((item && item.countable && !item.deleted && item.moved === this.currMove) ? item.length : 0) - this.rel + if (item && item.content.constructor === ContentMove) { + item = item.left + } else { + len += ((item && item.countable && !item.deleted && item.moved === this.currMove) ? item.length : 0) - this.rel + } this.rel = 0 while (item && len > 0) { if (item.countable && !item.deleted && item.moved === this.currMove) { diff --git a/tests/y-array.tests.js b/tests/y-array.tests.js index e9c0c055..2a1b4452 100644 --- a/tests/y-array.tests.js +++ b/tests/y-array.tests.js @@ -668,7 +668,7 @@ const compareTestobjects = cmp => { * @param {t.TestCase} tc */ export const testRepeatGeneratingYarrayTests6 = tc => { - compareTestobjects(applyRandomTests(tc, arrayTransactions, 9, monitorArrayTestObject)) + compareTestobjects(applyRandomTests(tc, arrayTransactions, 6, monitorArrayTestObject)) } /**