fix ListIterator backwards iteration within moved ranges

This commit is contained in:
Kevin Jahns
2022-03-29 16:55:22 +02:00
parent c4b28aceec
commit f65d1b8475
3 changed files with 36 additions and 23 deletions

View File

@@ -185,7 +185,7 @@ export class ContentMove {
if (!start.deleted) {
const currMoved = start.moved
const nextPrio = currMoved ? /** @type {ContentMove} */ (currMoved.content).priority : -1
if (currMoved === null || adaptPriority || nextPrio < this.priority || currMoved.id.client < item.id.client || (currMoved.id.client === item.id.client && currMoved.id.clock < item.id.clock)) {
if (adaptPriority || nextPrio < this.priority || (currMoved != null && nextPrio === this.priority && (currMoved.id.client < item.id.client || (currMoved.id.client === item.id.client && currMoved.id.clock < item.id.clock)))) {
if (currMoved !== null) {
this.overrides.add(currMoved)
}
@@ -198,7 +198,7 @@ export class ContentMove {
transaction.prevMoved.set(start, prevMove)
}
start.moved = item
} else {
} else if (currMoved != null) {
/** @type {ContentMove} */ (currMoved.content).overrides.add(item)
}
}

View File

@@ -118,6 +118,7 @@ export class ListIterator {
}
let item = this.nextItem
this.index += len
// @todo this condition is not needed, better to remove it (can always be applied)
if (this.rel) {
len += this.rel
this.rel = 0
@@ -197,11 +198,9 @@ export class ListIterator {
this.rel -= len
return this
}
let item = this.nextItem && this.nextItem.left
if (this.rel) {
len -= this.rel
this.rel = 0
}
let item = this.nextItem
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) {
len -= item.length