From bcee8ce04bf6b2b4fc66455606bb0d6d95ab3974 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Thu, 31 Oct 2019 11:34:29 +0300 Subject: [PATCH] KT-34692: Invoke `ScratchAction::update` without `invokeLater` - `invokeLater` is bad here, since `AnAction::update` must update action look immediately, not later in the future - Because of `invokeLater`, `RunScratchAction` wasn't properly rendered in the context menu - `invokeLater` was added in the a24da280caf769b099401ae93385b7b04f98c1ae to fix EA-210180 - EA-210180 is not reproducible; however, the main reason of the exception is that `AnAction::update` was called not from EDT, but from regular thread updating "Run From Here" (>>) gutter actions - all exception under EA-210180 are from 1.3.50; my guess is that those exceptions were caused by changes in scratch editor implementation details and will not appear again; if they will, we will need to investigate them - ^KT-34692 Fixed --- .../org/jetbrains/kotlin/idea/scratch/actions/ScratchAction.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/ScratchAction.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/ScratchAction.kt index aff99969d1a..a1c64a19f79 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/ScratchAction.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/ScratchAction.kt @@ -15,7 +15,7 @@ import org.jetbrains.kotlin.idea.scratch.getScratchFileFromSelectedEditor import javax.swing.Icon abstract class ScratchAction(message: String, icon: Icon) : AnAction(message, message, icon) { - override fun update(e: AnActionEvent) = ApplicationManager.getApplication().invokeLater { + override fun update(e: AnActionEvent) { val scratchFile = e.getData(CommonDataKeys.EDITOR) ?.let { TextEditorProvider.getInstance().getTextEditor(it).getScratchFile() } ?: e.project?.let { getScratchFileFromSelectedEditor(it) }