diff --git a/packages/core/src/docs/data-model/text-x/apply-utils/update-apply.ts b/packages/core/src/docs/data-model/text-x/apply-utils/update-apply.ts index 737600cc5c0..d916e7927b3 100644 --- a/packages/core/src/docs/data-model/text-x/apply-utils/update-apply.ts +++ b/packages/core/src/docs/data-model/text-x/apply-utils/update-apply.ts @@ -536,20 +536,14 @@ function updateCustomDecorations( } if (coverType === UpdateDocsAttributeType.REPLACE) { - const removeIndex: number[] = []; for (let index = 0; index < customDecorations.length; index++) { const customDecoration = customDecorations[index]; const { startIndex, endIndex } = customDecoration; if (startIndex >= currentIndex && endIndex <= currentIndex + textLength - 1) { removeCustomDecorations.push(customDecoration); - removeIndex.push(index); } } - for (let index = removeIndex.length - 1; index >= 0; index--) { - customDecorations.splice(removeIndex[index], 1); - } - updateDataCustomDecorations?.forEach((customDecoration) => { const { startIndex, endIndex } = customDecoration; customDecorations.push({ @@ -576,13 +570,13 @@ function updateCustomDecorations( }); } } + } - for (const removeCustomDecoration of removeCustomDecorations) { - const { id } = removeCustomDecoration; - const index = customDecorations.findIndex((d) => d.id === id); - if (index !== -1) { - customDecorations.splice(index, 1); - } + for (const removeCustomDecoration of removeCustomDecorations) { + const { id } = removeCustomDecoration; + const index = customDecorations.findIndex((d) => d.id === id); + if (index !== -1) { + customDecorations.splice(index, 1); } }