From 4c19fef998a1d06d6090009f40a3fc9cfe650a25 Mon Sep 17 00:00:00 2001 From: nimishclickup <109546805+nimishclickup@users.noreply.github.com> Date: Sat, 4 Feb 2023 20:28:39 -0800 Subject: [PATCH] Don't update the current attributes in case of delete --- src/types/YText.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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)