fixed 10 tests
This commit is contained in:
@@ -28,6 +28,8 @@ import * as binary from 'lib0/binary.js'
|
||||
* @param {AbstractItem} leftItem
|
||||
* @param {number} diff
|
||||
* @return {AbstractItem}
|
||||
*
|
||||
* @todo remove store param0
|
||||
*/
|
||||
export const splitItem = (store, leftItem, diff) => {
|
||||
const id = leftItem.id
|
||||
@@ -35,7 +37,7 @@ export const splitItem = (store, leftItem, diff) => {
|
||||
const rightItem = leftItem.copy(
|
||||
createID(id.client, id.clock + diff),
|
||||
leftItem,
|
||||
leftItem.lastId,
|
||||
createID(id.client, id.clock + diff - 1),
|
||||
leftItem.right,
|
||||
leftItem.rightOrigin,
|
||||
leftItem.parent,
|
||||
|
||||
@@ -12,8 +12,9 @@ import {
|
||||
getItemType,
|
||||
changeItemRefOffset,
|
||||
GC,
|
||||
splitItem,
|
||||
compareIDs,
|
||||
Transaction, ID, AbstractType // eslint-disable-line
|
||||
StructStore, Transaction, ID, AbstractType // eslint-disable-line
|
||||
} from '../internals.js'
|
||||
|
||||
import * as encoding from 'lib0/encoding.js'
|
||||
@@ -52,13 +53,27 @@ export class ItemDeleted extends AbstractItem {
|
||||
copy (id, left, origin, right, rightOrigin, parent, parentSub) {
|
||||
return new ItemDeleted(id, left, origin, right, rightOrigin, parent, parentSub, this.length)
|
||||
}
|
||||
/**
|
||||
* @param {StructStore} store
|
||||
* @param {number} diff
|
||||
*/
|
||||
splitAt (store, diff) {
|
||||
/**
|
||||
* @type {ItemDeleted}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const right = splitItem(store, this, diff)
|
||||
right._len -= diff
|
||||
this._len = diff
|
||||
return right
|
||||
}
|
||||
/**
|
||||
* @param {ItemDeleted} right
|
||||
* @return {boolean}
|
||||
*/
|
||||
mergeWith (right) {
|
||||
if (compareIDs(right.origin, this.lastId) && this.right === right) {
|
||||
this._len += right.length
|
||||
if (compareIDs(right.origin, this.lastId) && this.right === right && compareIDs(this.rightOrigin, right.rightOrigin)) {
|
||||
this._len += right._len
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -66,7 +66,7 @@ export class ItemJSON extends AbstractItem {
|
||||
* @type {ItemJSON}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const right = splitItem(this, diff)
|
||||
const right = splitItem(store, this, diff)
|
||||
right.content = this.content.splice(diff)
|
||||
return right
|
||||
}
|
||||
@@ -75,7 +75,7 @@ export class ItemJSON extends AbstractItem {
|
||||
* @return {boolean}
|
||||
*/
|
||||
mergeWith (right) {
|
||||
if (compareIDs(right.origin, this.lastId) && this.right === right) {
|
||||
if (compareIDs(right.origin, this.lastId) && this.right === right && compareIDs(this.rightOrigin, right.rightOrigin)) {
|
||||
this.content = this.content.concat(right.content)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ export class ItemString extends AbstractItem {
|
||||
* @return {boolean}
|
||||
*/
|
||||
mergeWith (right) {
|
||||
if (compareIDs(right.origin, this.lastId) && this.right === right) {
|
||||
if (compareIDs(right.origin, this.lastId) && this.right === right && compareIDs(this.rightOrigin, right.rightOrigin)) {
|
||||
this.string += right.string
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -93,8 +93,8 @@ export class ItemType extends AbstractItem {
|
||||
* @param {Transaction} transaction
|
||||
*/
|
||||
integrate (transaction) {
|
||||
this.type._integrate(transaction.y, this)
|
||||
super.integrate(transaction)
|
||||
this.type._integrate(transaction.y, this)
|
||||
}
|
||||
/**
|
||||
* @param {encoding.Encoder} encoder
|
||||
|
||||
Reference in New Issue
Block a user