make sure that markers are correct without reinit

This commit is contained in:
Kevin Jahns 2021-12-06 21:22:18 +01:00
parent 4356d70ed0
commit 6230abb78c
3 changed files with 1 additions and 16 deletions

View File

@ -594,6 +594,7 @@ export class Item extends AbstractStruct {
if (searchMarker) {
for (let i = searchMarker.length - 1; i >= 0; i--) {
if (searchMarker[i].nextItem === right) {
// @todo do something more efficient than splicing..
searchMarker.splice(i, 1)
}
}

View File

@ -43,7 +43,6 @@ export const useSearchMarker = (tr, yarray, index, f) => {
const sm = new ListIterator(yarray).forward(tr, index)
searchMarker.push(sm)
if (sm.nextItem) sm.nextItem.marker = true
return f(sm)
}
const sm = searchMarker.reduce(
(a, b, arrayIndex) => math.abs(index - a.index) < math.abs(index - b.index) ? a : b
@ -54,8 +53,6 @@ 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

@ -1,5 +1,4 @@
import * as error from 'lib0/error'
import { getItem } from 'yjs'
import {
getItemCleanStart,
@ -74,18 +73,6 @@ export class ListIterator {
return iter
}
/**
* @param {Transaction} tr
*/
reinit (tr) {
if (this.nextItem) {
const nextId = this.nextItem.id
const reinitId = createID(nextId.client, nextId.clock + this.rel)
this.nextItem = getItem(tr.doc.store, reinitId)
this.rel = reinitId.clock - this.nextItem.id.clock
}
}
/**
* @type {Item | null}
*/