skip formatting cleanup when the ytext doesnt have any ContentFormat
also skip iterating the deleted structs entirely when none of the changed ytext had ContentFormat
This commit is contained in:
parent
c398448152
commit
08250a9a6c
@ -508,7 +508,8 @@ export const cleanupYTextAfterTransaction = transaction => {
|
|||||||
if (item instanceof GC || needFullCleanup.has(/** @type {YText} */ (item.parent))) {
|
if (item instanceof GC || needFullCleanup.has(/** @type {YText} */ (item.parent))) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const parent = /** @type {YText} */ (item.parent)
|
const parent = item.parent
|
||||||
|
if (parent instanceof YText && parent._needFormattingCleanup) {
|
||||||
if (item.content.constructor === ContentFormat) {
|
if (item.content.constructor === ContentFormat) {
|
||||||
needFullCleanup.add(parent)
|
needFullCleanup.add(parent)
|
||||||
} else {
|
} else {
|
||||||
@ -517,6 +518,7 @@ export const cleanupYTextAfterTransaction = transaction => {
|
|||||||
// Contextless: it is not necessary to compute currentAttributes for the affected position.
|
// Contextless: it is not necessary to compute currentAttributes for the affected position.
|
||||||
cleanupContextlessFormattingGap(t, item)
|
cleanupContextlessFormattingGap(t, item)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
// If a formatting item was inserted, we simply clean the whole type.
|
// If a formatting item was inserted, we simply clean the whole type.
|
||||||
// We need to compute currentAttributes for the current position anyway.
|
// We need to compute currentAttributes for the current position anyway.
|
||||||
@ -862,6 +864,7 @@ export class YText extends AbstractType {
|
|||||||
* @type {Array<ArraySearchMarker>}
|
* @type {Array<ArraySearchMarker>}
|
||||||
*/
|
*/
|
||||||
this._searchMarker = []
|
this._searchMarker = []
|
||||||
|
this._needFormattingCleanup = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -910,9 +913,18 @@ export class YText extends AbstractType {
|
|||||||
super._callObserver(transaction, parentSubs)
|
super._callObserver(transaction, parentSubs)
|
||||||
const event = new YTextEvent(this, transaction, parentSubs)
|
const event = new YTextEvent(this, transaction, parentSubs)
|
||||||
callTypeObservers(this, transaction, event)
|
callTypeObservers(this, transaction, event)
|
||||||
|
this._needFormattingCleanup = false
|
||||||
// If a remote change happened, we try to cleanup potential formatting duplicates.
|
// If a remote change happened, we try to cleanup potential formatting duplicates.
|
||||||
if (!transaction.local) {
|
if (!transaction.local && !transaction._needFormattingCleanup) {
|
||||||
|
let item = this._start
|
||||||
|
while (item) {
|
||||||
|
if (!item.deleted && item.content.constructor === ContentFormat) {
|
||||||
|
this._needFormattingCleanup = true
|
||||||
transaction._needFormattingCleanup = true
|
transaction._needFormattingCleanup = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
item = item.right
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user