Delete all children of ItemType when it is deleted

This commit is contained in:
Kevin Jahns
2019-04-26 12:29:28 +02:00
parent 1d0f9faa91
commit 21d86cd2be
6 changed files with 44 additions and 25 deletions

View File

@@ -425,6 +425,7 @@ export class AbstractItem extends AbstractStruct {
* @private
*/
gc (transaction, store) {
this.delete(transaction)
let r
if (this.parent._item !== null && this.parent._item.deleted) {
r = new GC(this.id, this.length)

View File

@@ -100,9 +100,21 @@ export class ItemType extends AbstractItem {
* @private
*/
delete (transaction) {
super.delete(transaction)
transaction.changed.delete(this.type)
transaction.changedParentTypes.delete(this.type)
if (!this.deleted) {
super.delete(transaction)
let item = this.type._start
while (item !== null) {
if (!item.deleted) {
item.delete(transaction)
}
item = item.right
}
this.type._map.forEach(item => {
item.delete(transaction)
})
transaction.changed.delete(this.type)
transaction.changedParentTypes.delete(this.type)
}
}
/**