diff --git a/src/types/YText.js b/src/types/YText.js index 788f67b4..d1cdf781 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -382,12 +382,17 @@ const cleanupFormattingGap = (transaction, start, curr, startAttributes, currAtt switch (content.constructor) { case ContentFormat: { const { key, value } = /** @type {ContentFormat} */ (content) - if ((endAttributes.get(key) || null) !== value || (startAttributes.get(key) || null) === value) { + const startAttrValue = startAttributes.get(key) || null + if ((endAttributes.get(key) || null) !== value || startAttrValue === value) { // 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) { - currAttributes.delete(key) + if (startAttrValue === null) { + currAttributes.delete(key) + } else { + currAttributes.set(key, startAttrValue) + } } } break diff --git a/tests/y-text.tests.js b/tests/y-text.tests.js index fb64d95d..48622673 100644 --- a/tests/y-text.tests.js +++ b/tests/y-text.tests.js @@ -206,7 +206,6 @@ export const testDeltaBug = _tc => { } ] ytext.applyDelta(addingSpace) - debugger const addingList = [ { retain: 12 @@ -411,7 +410,6 @@ export const testDeltaBug = _tc => { } ] t.compare(result, expectedResult) - debugger } /**