fix gc when item is deleted in observer call
This commit is contained in:
@@ -421,13 +421,14 @@ export class AbstractItem extends AbstractStruct {
|
||||
/**
|
||||
* @param {Transaction} transaction
|
||||
* @param {StructStore} store
|
||||
* @param {boolean} parentGCd
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
gc (transaction, store) {
|
||||
gc (transaction, store, parentGCd) {
|
||||
this.delete(transaction)
|
||||
let r
|
||||
if (this.parent._item !== null && this.parent._item.deleted) {
|
||||
if (parentGCd) {
|
||||
r = new GC(this.id, this.length)
|
||||
} else {
|
||||
r = new ItemDeleted(this.id, this.left, this.origin, this.right, this.rightOrigin, this.parent, this.parentSub, this.length)
|
||||
|
||||
@@ -85,6 +85,19 @@ export class ItemDeleted extends AbstractItem {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Transaction} transaction
|
||||
* @param {StructStore} store
|
||||
* @param {boolean} parentGCd
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
gc (transaction, store, parentGCd) {
|
||||
if (parentGCd) {
|
||||
super.gc(transaction, store, parentGCd)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param {encoding.Encoder} encoder
|
||||
* @param {number} offset
|
||||
|
||||
@@ -124,13 +124,13 @@ export class ItemType extends AbstractItem {
|
||||
gcChildren (transaction, store) {
|
||||
let item = this.type._start
|
||||
while (item !== null) {
|
||||
item.gc(transaction, store)
|
||||
item.gc(transaction, store, true)
|
||||
item = item.right
|
||||
}
|
||||
this.type._start = null
|
||||
this.type._map.forEach(item => {
|
||||
while (item !== null) {
|
||||
item.gc(transaction, store)
|
||||
item.gc(transaction, store, true)
|
||||
// @ts-ignore
|
||||
item = item.left
|
||||
}
|
||||
@@ -141,10 +141,11 @@ export class ItemType extends AbstractItem {
|
||||
/**
|
||||
* @param {Transaction} transaction
|
||||
* @param {StructStore} store
|
||||
* @param {boolean} parentGCd
|
||||
*/
|
||||
gc (transaction, store) {
|
||||
gc (transaction, store, parentGCd) {
|
||||
this.gcChildren(transaction, store)
|
||||
super.gc(transaction, store)
|
||||
super.gc(transaction, store, parentGCd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user