From a057bf1cf0dae3ac06db4db913548748ff3ee900 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Fri, 19 Nov 2021 17:27:23 +0100 Subject: [PATCH] fix disconnect issue --- src/utils/ListIterator.js | 10 ++++------ tests/y-text.tests.js | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/utils/ListIterator.js b/src/utils/ListIterator.js index 7e3463a5..6c1c3dac 100644 --- a/src/utils/ListIterator.js +++ b/src/utils/ListIterator.js @@ -289,13 +289,12 @@ export class ListIterator { /** * @type {Item | null} */ - let item = this.nextItem if (this.rel > 0) { /** * @type {ID} */ - const itemid = /** @type {Item} */ (item).id - item = getItemCleanStart(tr, createID(itemid.client, itemid.clock + this.rel)) + const itemid = /** @type {Item} */ (this.nextItem).id + this.nextItem = getItemCleanStart(tr, createID(itemid.client, itemid.clock + this.rel)) this.rel = 0 } const parent = this.type @@ -358,12 +357,11 @@ export class ListIterator { }) packJsonContent() if (right === null && left !== null) { - item = left + this.nextItem = left this.reachedEnd = true } else { - item = right + this.nextItem = right } - this.nextItem = item } /** diff --git a/tests/y-text.tests.js b/tests/y-text.tests.js index 2a555237..f4ede339 100644 --- a/tests/y-text.tests.js +++ b/tests/y-text.tests.js @@ -327,6 +327,7 @@ export const testFormattingDeltaUnnecessaryAttributeChange = tc => { * @param {t.TestCase} tc */ export const testInsertAndDeleteAtRandomPositions = tc => { + // @todo optimize to run at least as fast as previous marker approach const N = 100000 const { text0 } = init(tc, { users: 1 }) const gen = tc.prng