From b21925a4f17aa7578bab68f27c939ed4125c255f Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Wed, 20 Mar 2024 22:34:20 +0800 Subject: [PATCH] fix(devins-lang): improve process handler creation for IDE 222 version Improve the creation of process handler for better efficiency and reliability. Replace the old method with a more concise and efficient implementation, guaranteeing proper handling of the output. --- .../language/compiler/exec/ShellInsCommand.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/ShellInsCommand.kt b/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/ShellInsCommand.kt index 882354eaa5..24675b2aca 100644 --- a/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/ShellInsCommand.kt +++ b/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/ShellInsCommand.kt @@ -5,19 +5,14 @@ import com.intellij.execution.DefaultExecutionResult import com.intellij.execution.ExecutionException import com.intellij.execution.configurations.* import com.intellij.execution.process.KillableProcessHandler -import com.intellij.execution.process.ProcessHandler import com.intellij.execution.process.ProcessTerminatedListener -import com.intellij.execution.runners.ExecutionEnvironment -import com.intellij.execution.runners.ProgramRunner import com.intellij.execution.ui.ConsoleView -import com.intellij.execution.ui.RunContentDescriptor -import com.intellij.execution.ui.RunContentManager import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.project.Project import com.intellij.sh.run.ShConfigurationType import com.intellij.sh.run.ShRunner import com.intellij.terminal.TerminalExecutionConsole +import com.intellij.util.io.BaseDataReader import com.intellij.util.io.BaseOutputReader class ShellInsCommand(val myProject: Project, val prop: String) : InsCommand { @@ -65,11 +60,16 @@ class ShellInsCommand(val myProject: Project, val prop: String) : InsCommand { } @Throws(ExecutionException::class) - private fun createProcessHandler(commandLine: GeneralCommandLine): ProcessHandler { - return object : KillableProcessHandler(commandLine) { - override fun readerOptions(): BaseOutputReader.Options { - return BaseOutputReader.Options.forTerminalPtyProcess() + private fun createProcessHandler(commandLine: GeneralCommandLine) = + object : KillableProcessHandler(commandLine) { + override fun readerOptions() = object : BaseOutputReader.Options() { + override fun policy(): BaseDataReader.SleepingPolicy { + return BaseDataReader.SleepingPolicy.BLOCKING + } + + override fun splitToLines(): Boolean { + return false + } } } - } }