mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[kotlin] J2K copy-paste: commit document correctly
KTIJ-28714 IJ-CR-150614 (cherry picked from commit 406f144ef15f81becf35a59bb3d844885d959683) GitOrigin-RevId: f60767b9d805b84eeb7c46038a05680113019d99
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fe5b7f66f2
commit
143ae41304
@@ -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<FqName>
|
||||
): TextRange? {
|
||||
if (referenceData.isEmpty() && importsToAdd.isEmpty()) return bounds
|
||||
PsiDocumentManager.getInstance(project).commitDocument(targetData.document)
|
||||
|
||||
val rangeMarker = targetData.document.createRangeMarker(bounds)
|
||||
rangeMarker.isGreedyToLeft = true
|
||||
|
||||
@@ -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<FqName>): TextRange? {
|
||||
if (importsToAdd.isEmpty()) return bounds
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitDocument(targetData.document)
|
||||
val rangeMarker = targetData.document.createRangeMarker(bounds).apply {
|
||||
isGreedyToLeft = true
|
||||
isGreedyToRight = true
|
||||
|
||||
Reference in New Issue
Block a user