Skip to content

Commit 41375c4

Browse files
committed
(#172) Run configuration: migrate to TerminalExecutionConsole
1 parent 04060b4 commit 41375c4

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/main/kotlin/com/intellij/plugin/powershell/ide/run/PowerShellScriptCommandLineState.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.intellij.plugin.powershell.ide.run
22

3+
import com.intellij.execution.DefaultExecutionResult
34
import com.intellij.execution.ExecutionException
4-
import com.intellij.execution.configurations.CommandLineState
5+
import com.intellij.execution.ExecutionResult
6+
import com.intellij.execution.Executor
57
import com.intellij.execution.configurations.PtyCommandLine
68
import com.intellij.execution.configurations.RunProfileState
79
import com.intellij.execution.process.KillableColoredProcessHandler
810
import com.intellij.execution.process.ProcessHandler
911
import com.intellij.execution.runners.ExecutionEnvironment
12+
import com.intellij.execution.runners.ProgramRunner
1013
import com.intellij.execution.util.ProgramParametersUtil
1114
import com.intellij.openapi.application.readAction
1215
import com.intellij.openapi.diagnostic.logger
@@ -15,15 +18,17 @@ import com.intellij.openapi.util.text.StringUtil
1518
import com.intellij.openapi.vfs.LocalFileSystem
1619
import com.intellij.plugin.powershell.lang.lsp.LSPInitMain
1720
import com.intellij.plugin.powershell.lang.lsp.languagehost.PowerShellNotInstalled
21+
import com.intellij.terminal.TerminalExecutionConsole
1822
import kotlinx.coroutines.Dispatchers
1923
import kotlinx.coroutines.withContext
2024
import java.io.File
2125
import java.nio.file.Path
2226
import java.util.regex.Pattern
2327
import kotlin.io.path.Path
2428

25-
class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellRunConfiguration, environment: ExecutionEnvironment) :
26-
CommandLineState(environment), RunProfileState {
29+
class PowerShellScriptCommandLineState(
30+
private val runConfiguration: PowerShellRunConfiguration,
31+
private val environment: ExecutionEnvironment) : RunProfileState {
2732

2833
lateinit var workingDirectory: Path
2934
suspend fun prepareExecution() {
@@ -39,7 +44,7 @@ class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellR
3944
)
4045
}
4146

42-
override fun startProcess(): ProcessHandler {
47+
private fun startProcess(): ProcessHandler {
4348
try {
4449
val command = buildCommand(
4550
runConfiguration.executablePath ?: LSPInitMain.getInstance().getPowerShellExecutable(),
@@ -48,6 +53,7 @@ class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellR
4853
runConfiguration.scriptParameters
4954
)
5055
val commandLine = PtyCommandLine(command)
56+
.withConsoleMode(false)
5157
.withWorkDirectory(workingDirectory.toString())
5258

5359
runConfiguration.environmentVariables.configureCommandLine(commandLine, true)
@@ -90,6 +96,12 @@ class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellR
9096
}
9197
return commandString
9298
}
99+
100+
override fun execute(executor: Executor?, runner: ProgramRunner<*>): ExecutionResult? {
101+
val process = startProcess()
102+
val console = TerminalExecutionConsole(environment.project, process)
103+
return DefaultExecutionResult(console, process)
104+
}
93105
}
94106

95107
private val logger = logger<PowerShellScriptCommandLineState>()

0 commit comments

Comments
 (0)