fix insert in y-text

This commit is contained in:
Kevin Jahns 2017-12-02 01:45:22 -08:00
parent c6e671b1d5
commit 3595f14da7

View File

@ -29,14 +29,17 @@ export default class YText extends YArray {
let right = this._start
let count = 0
while (right !== null) {
if (count <= pos && pos < count + right._length) {
const rightLen = right._deleted ? 0 : (right._length - 1)
if (count <= pos && pos <= count + rightLen) {
const splitDiff = pos - count
right = right._splitAt(this._y, pos - count)
right = right._splitAt(this._y, splitDiff)
left = right._left
count += splitDiff
break
}
count += right._length
if (!right._deleted) {
count += right._length
}
left = right
right = right._right
}