fix attribute update issue - fixes #503

This commit is contained in:
Kevin Jahns 2023-03-02 19:08:01 +01:00
parent 658c520b93
commit bf338d8040
2 changed files with 1242 additions and 3 deletions

View File

@ -367,15 +367,16 @@ const cleanupFormattingGap = (transaction, start, curr, startAttributes, currAtt
const endAttributes = map.copy(currAttributes)
while (end && (!end.countable || end.deleted)) {
if (!end.deleted && end.content.constructor === ContentFormat) {
// @todo should set endAttributes[end.key] = end and then compare identities instead of values
updateCurrentAttributes(endAttributes, /** @type {ContentFormat} */ (end.content))
}
end = end.right
}
let cleanups = 0
let reachedEndOfCurr = false
let reachedCurr = false
while (start !== end) {
if (curr === start) {
reachedEndOfCurr = true
reachedCurr = true
}
if (!start.deleted) {
const content = start.content
@ -387,7 +388,7 @@ const cleanupFormattingGap = (transaction, start, curr, startAttributes, currAtt
// Either this format is overwritten or it is not necessary because the attribute already existed.
start.delete(transaction)
cleanups++
if (!reachedEndOfCurr && (currAttributes.get(key) || null) === value && (startAttributes.get(key) || null) !== value) {
if (!reachedCurr && (currAttributes.get(key) || null) === value && startAttrValue !== value) {
if (startAttrValue === null) {
currAttributes.delete(key)
} else {
@ -395,6 +396,9 @@ const cleanupFormattingGap = (transaction, start, curr, startAttributes, currAtt
}
}
}
if (!reachedCurr && !start.deleted) {
updateCurrentAttributes(currAttributes, /** @type {ContentFormat} */ (content))
}
break
}
}

File diff suppressed because it is too large Load Diff