scan the document once for all ytexts when cleaning up

Fixes #522 but is a scarier change
This commit is contained in:
Noel Levy
2023-06-12 18:20:06 -07:00
parent 3741f43a11
commit 08801dd406
2 changed files with 33 additions and 40 deletions

View File

@@ -115,9 +115,9 @@ export class Transaction {
*/
this.subdocsLoaded = new Set()
/**
* @type {Array<YText>}
* @type {Set<YText>}
*/
this._yTexts = []
this._yTexts = new Set()
}
}
@@ -299,11 +299,9 @@ const cleanupTransactions = (transactionCleanups, i) => {
fs.push(() => doc.emit('afterTransaction', [transaction, doc]))
})
callAll(fs, [])
if (transaction._yTexts.length > 0) {
if (transaction._yTexts.size > 0) {
transact(doc, () => {
transaction._yTexts.forEach(yText => {
yText._cleanup(transaction)
})
YText._cleanup(transaction)
})
}
} finally {