From f5781f836623d7a3a5f9265bfcaee6f162772f6e Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Mon, 6 Dec 2021 22:07:46 +0100 Subject: [PATCH] update searchmarkers after insert correctly --- src/utils/ListIterator.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/ListIterator.js b/src/utils/ListIterator.js index 7754f5a6..2038b1c2 100644 --- a/src/utils/ListIterator.js +++ b/src/utils/ListIterator.js @@ -311,12 +311,13 @@ export class ListIterator { } /** + * Important: you must update markers after calling this method! + * * @param {Transaction} tr * @param {Array} content */ insertContents (tr, content) { this._splitRel(tr) - const sm = this.type._searchMarker const parent = this.type const store = tr.doc.store const ownClientId = tr.doc.clientID @@ -339,9 +340,6 @@ export class ListIterator { } else { this.nextItem = right } - if (sm) { - updateMarkerChanges(sm, this.index, content.length, this) - } } /** @@ -363,6 +361,7 @@ export class ListIterator { */ insertArrayValue (tr, values) { this._splitRel(tr) + const sm = this.type._searchMarker /** * @type {Array} */ @@ -412,6 +411,9 @@ export class ListIterator { packJsonContent() this.insertContents(tr, contents) this.index += values.length + if (sm) { + updateMarkerChanges(sm, this.index, values.length, this) + } } /**