reinit search marker after transaction

This commit is contained in:
Kevin Jahns
2021-12-06 21:00:20 +01:00
parent 0948229422
commit 4356d70ed0
3 changed files with 26 additions and 9 deletions

View File

@@ -54,6 +54,8 @@ export const useSearchMarker = (tr, yarray, index, f) => {
const prevItem = /** @type {Item} */ (sm.nextItem)
if (createFreshMarker) {
searchMarker.push(fsm)
} else {
fsm.reinit(tr)
}
const diff = fsm.index - index
if (diff > 0) {

View File

@@ -124,14 +124,16 @@ export class YArray extends AbstractType {
* @param {Array<T>} content The array of content
*/
insert (index, content) {
if (this.doc !== null) {
transact(this.doc, transaction => {
useSearchMarker(transaction, this, index, walker =>
walker.insertArrayValue(transaction, content)
)
})
} else {
/** @type {Array<any>} */ (this._prelimContent).splice(index, 0, ...content)
if (content.length > 0) {
if (this.doc !== null) {
transact(this.doc, transaction => {
useSearchMarker(transaction, this, index, walker =>
walker.insertArrayValue(transaction, content)
)
})
} else {
/** @type {Array<any>} */ (this._prelimContent).splice(index, 0, ...content)
}
}
}