Fix for KT-14585 J2K, ConvertJavaCopyPasteProcessor shows a dialog under write action

This commit is contained in:
Simon Ogorodnik
2016-11-07 19:27:50 +03:00
parent 61ef26614d
commit 7e82dd9adc
@@ -135,15 +135,19 @@ class ConvertJavaCopyPasteProcessor : CopyPastePostProcessor<TextBlockTransferab
val (text, referenceData, explicitImports) = conversionResult!!
text!! // otherwise we should get true from doConversionAndInsertImportsIfUnchanged and return above
val boundsAfterReplace =
runWriteAction {
val startOffset = bounds.startOffset
document.replaceString(startOffset, bounds.endOffset, text)
val endOffsetAfterCopy = startOffset + text.length
editor.caretModel.moveToOffset(endOffsetAfterCopy)
TextRange(startOffset, endOffsetAfterCopy)
}
val newBounds = insertImports(boundsAfterReplace, referenceData, explicitImports)
runWriteAction {
val startOffset = bounds.startOffset
document.replaceString(startOffset, bounds.endOffset, text)
val endOffsetAfterCopy = startOffset + text.length
editor.caretModel.moveToOffset(endOffsetAfterCopy)
val newBounds = insertImports(TextRange(startOffset, endOffsetAfterCopy), referenceData, explicitImports)
PsiDocumentManager.getInstance(project).commitAllDocuments()
AfterConversionPass(project, J2kPostProcessor(formatCode = true)).run(targetFile, newBounds)