mirror of
https://github.com/yjs/yjs.git
synced 2026-02-24 04:01:14 +01:00
Avoid copying attribute map when deleting
Calling cleanupFormattingGap should not make a copy of the attributes because it needs to be able to update them.
This commit is contained in:
@@ -465,7 +465,7 @@ const deleteText = (transaction, currPos, length) => {
|
||||
currPos.forward()
|
||||
}
|
||||
if (start) {
|
||||
cleanupFormattingGap(transaction, start, currPos.right, startAttrs, map.copy(currPos.currentAttributes))
|
||||
cleanupFormattingGap(transaction, start, currPos.right, startAttrs, currPos.currentAttributes)
|
||||
}
|
||||
const parent = /** @type {AbstractType<any>} */ (/** @type {Item} */ (currPos.left || currPos.right).parent)
|
||||
if (parent._searchMarker) {
|
||||
|
||||
@@ -138,6 +138,28 @@ export const testNotMergeEmptyLinesFormat = tc => {
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {t.TestCase} tc
|
||||
*/
|
||||
export const testPreserveAttributesThroughDelete = tc => {
|
||||
const ydoc = new Y.Doc()
|
||||
const testText = ydoc.getText('test');
|
||||
testText.applyDelta([
|
||||
{ insert: 'Text' },
|
||||
{ insert: '\n', attributes: { title: true } },
|
||||
{ insert: '\n' }
|
||||
])
|
||||
testText.applyDelta([
|
||||
{ retain: 4 },
|
||||
{ delete: 1 },
|
||||
{ retain: 1, attributes: { title: true } },
|
||||
])
|
||||
t.compare(testText.toDelta(), [
|
||||
{ insert: 'Text' },
|
||||
{ insert: '\n', attributes: { title: true } },
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {t.TestCase} tc
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user