diff --git a/src/types/YText.js b/src/types/YText.js index 887eb6cb..5739b733 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -55,6 +55,26 @@ export class ItemTextListPosition { this.currentAttributes = currentAttributes } + /** + * Don't update the attributes if it is going to be deleted + */ + forwardWithOutUpdatingAttributes () { + if (this.right === null) { + error.unexpectedCase() + } + switch (this.right.content.constructor) { + case ContentFormat: + break + default: + if (!this.right.deleted) { + this.index += this.right.length + } + break + } + this.left = this.right + this.right = this.right.right + } + /** * Only call this if you know that this.right is defined */ @@ -488,7 +508,7 @@ const deleteText = (transaction, currPos, length) => { break } } - currPos.forward() + currPos.forwardWithOutUpdatingAttributes() } if (start) { cleanupFormattingGap(transaction, start, currPos.right, startAttrs, currPos.currentAttributes)