J2K: do not run runUndoTransparentAction outside EDT
#KT-39739 fixed
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.idea.util
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.command.CommandProcessor
|
||||
|
||||
enum class ActionRunningMode {
|
||||
RUN_IN_CURRENT_THREAD,
|
||||
@@ -19,7 +20,9 @@ inline fun <T> ActionRunningMode.runAction(crossinline action: () -> T): T = whe
|
||||
ActionRunningMode.RUN_IN_EDT -> {
|
||||
var result: T? = null
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
result = ApplicationManager.getApplication().runWriteAction<T> { action() }
|
||||
CommandProcessor.getInstance().runUndoTransparentAction {
|
||||
result = ApplicationManager.getApplication().runWriteAction<T> { action() }
|
||||
}
|
||||
}
|
||||
result!!
|
||||
}
|
||||
|
||||
+11
-13
@@ -28,20 +28,18 @@ class ShortenReferenceProcessing : FileBasedPostProcessing() {
|
||||
}
|
||||
|
||||
override fun runProcessing(file: KtFile, allFiles: List<KtFile>, rangeMarker: RangeMarker?, converterContext: NewJ2kConverterContext) {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction {
|
||||
if (rangeMarker != null) {
|
||||
if (rangeMarker.isValid) {
|
||||
ShortenReferences.DEFAULT.process(
|
||||
file,
|
||||
rangeMarker.startOffset,
|
||||
rangeMarker.endOffset,
|
||||
filter,
|
||||
actionRunningMode = ActionRunningMode.RUN_IN_EDT
|
||||
)
|
||||
}
|
||||
} else {
|
||||
ShortenReferences.DEFAULT.process(file, filter, actionRunningMode = ActionRunningMode.RUN_IN_EDT)
|
||||
if (rangeMarker != null) {
|
||||
if (rangeMarker.isValid) {
|
||||
ShortenReferences.DEFAULT.process(
|
||||
file,
|
||||
rangeMarker.startOffset,
|
||||
rangeMarker.endOffset,
|
||||
filter,
|
||||
actionRunningMode = ActionRunningMode.RUN_IN_EDT
|
||||
)
|
||||
}
|
||||
} else {
|
||||
ShortenReferences.DEFAULT.process(file, filter, actionRunningMode = ActionRunningMode.RUN_IN_EDT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user