From 8d4ca4d1c596304997ee54d958d5cd9872d50f11 Mon Sep 17 00:00:00 2001 From: Natalia Selezneva Date: Wed, 26 Dec 2018 14:29:57 +0300 Subject: [PATCH] Scratch: Fix "Read access is allowed from event dispatch thread or inside read-action only" ^KT-28958 Fixed --- .../kotlin/idea/scratch/repl/KtScratchReplExecutor.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/repl/KtScratchReplExecutor.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/repl/KtScratchReplExecutor.kt index 73b3a6d9f56..daaf7f11965 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/repl/KtScratchReplExecutor.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/repl/KtScratchReplExecutor.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.scratch.repl import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.process.OSProcessHandler import com.intellij.execution.process.ProcessOutputTypes +import com.intellij.openapi.application.runReadAction import com.intellij.openapi.util.Key import org.jetbrains.kotlin.cli.common.repl.replInputAsXml import org.jetbrains.kotlin.cli.common.repl.replNormalizeLineBreaks @@ -52,7 +53,7 @@ class KtScratchReplExecutor(file: ScratchFile) : ScratchExecutor(file) { file.getExpressions().forEach { expression -> history.addEntry(expression) - sendCommandToProcess(expression.element.text) + sendCommandToProcess(runReadAction { expression.element.text }) } sendCommandToProcess(":quit")