diff --git a/src/tools/utils/editorOperationUtils.ts b/src/tools/utils/editorOperationUtils.ts index ba40642..16ed79f 100644 --- a/src/tools/utils/editorOperationUtils.ts +++ b/src/tools/utils/editorOperationUtils.ts @@ -60,7 +60,8 @@ function splitOperationText ( if (rangeText != null && rangeText !== '') { const rangeTextIndex = textToSplit.indexOf(rangeText) if (rangeTextIndex !== -1) { - splitText.push(textToSplit.slice(0, rangeTextIndex)) + const endIndex = textToSplit.endsWith('\n') ? rangeTextIndex - 1 : rangeTextIndex + splitText.push(textToSplit.slice(0, endIndex)) textToSplit = textToSplit.slice(rangeTextIndex + rangeText.length) } else { splitText.push(textToSplit) @@ -71,7 +72,7 @@ function splitOperationText ( } if (textToSplit !== '') { - splitText.push(textToSplit) + splitText.push(textToSplit.endsWith('\n') ? textToSplit.slice(0, textToSplit.length - 1) : textToSplit) } return splitText } diff --git a/src/tools/utils/rangeUtils.ts b/src/tools/utils/rangeUtils.ts index 85de807..70fc462 100644 --- a/src/tools/utils/rangeUtils.ts +++ b/src/tools/utils/rangeUtils.ts @@ -52,7 +52,7 @@ export function minusRanges ( } if (lastEndPosition.isBeforeOrEqual(uniqueRangeEndPosition)) { - firstRanges.push(monaco.Range.fromPositions(lastEndPosition, uniqueRangeEndPosition)) + firstRanges.push(monaco.Range.fromPositions(model.modifyPosition(lastEndPosition, 1), uniqueRangeEndPosition)) } return { firstRanges, secondRanges }