diff --git a/plugins/kotlin/j2k/k1.new/src/org/jetbrains/kotlin/j2k/copyPaste/K1J2KCopyPasteConverter.kt b/plugins/kotlin/j2k/k1.new/src/org/jetbrains/kotlin/j2k/copyPaste/K1J2KCopyPasteConverter.kt index 17baff5600b9..05b4da3112a8 100644 --- a/plugins/kotlin/j2k/k1.new/src/org/jetbrains/kotlin/j2k/copyPaste/K1J2KCopyPasteConverter.kt +++ b/plugins/kotlin/j2k/k1.new/src/org/jetbrains/kotlin/j2k/copyPaste/K1J2KCopyPasteConverter.kt @@ -52,10 +52,10 @@ class K1J2KCopyPasteConverter( runWriteAction { targetData.document.replaceString(targetData.bounds.startOffset, targetData.bounds.endOffset, changedText) editor.caretModel.moveToOffset(endOffsetAfterReplace) + PsiDocumentManager.getInstance(project).commitDocument(targetData.document) } val newBounds = restoreReferencesAndInsertImports(boundsAfterReplace, referenceData, importsToAdd) - PsiDocumentManager.getInstance(project).commitDocument(targetData.document) runPostProcessing(project, targetData.file, newBounds, converterContext, j2kKind) } @@ -131,7 +131,6 @@ class K1J2KCopyPasteConverter( importsToAdd: Collection ): TextRange? { if (referenceData.isEmpty() && importsToAdd.isEmpty()) return bounds - PsiDocumentManager.getInstance(project).commitDocument(targetData.document) val rangeMarker = targetData.document.createRangeMarker(bounds) rangeMarker.isGreedyToLeft = true diff --git a/plugins/kotlin/j2k/k2/src/org/jetbrains/kotlin/j2k/k2/copyPaste/K2J2KCopyPasteConverter.kt b/plugins/kotlin/j2k/k2/src/org/jetbrains/kotlin/j2k/k2/copyPaste/K2J2KCopyPasteConverter.kt index 937ffdbbf1c0..95c2de170e69 100644 --- a/plugins/kotlin/j2k/k2/src/org/jetbrains/kotlin/j2k/k2/copyPaste/K2J2KCopyPasteConverter.kt +++ b/plugins/kotlin/j2k/k2/src/org/jetbrains/kotlin/j2k/k2/copyPaste/K2J2KCopyPasteConverter.kt @@ -51,10 +51,10 @@ internal class K2J2KCopyPasteConverter( runWriteAction { targetData.document.replaceString(targetData.bounds.startOffset, targetData.bounds.endOffset, changedText) editor.caretModel.moveToOffset(endOffsetAfterReplace) + PsiDocumentManager.getInstance(project).commitDocument(targetData.document) } val newBounds = insertImports(boundsAfterReplace, importsToAdd) - PsiDocumentManager.getInstance(project).commitDocument(targetData.document) runPostProcessing(project, targetData.file, newBounds, converterContext, Kind.K2) } @@ -77,7 +77,6 @@ internal class K2J2KCopyPasteConverter( private fun insertImports(bounds: TextRange, importsToAdd: Collection): TextRange? { if (importsToAdd.isEmpty()) return bounds - PsiDocumentManager.getInstance(project).commitDocument(targetData.document) val rangeMarker = targetData.document.createRangeMarker(bounds).apply { isGreedyToLeft = true isGreedyToRight = true