1
1
package com.intellij.plugin.powershell.ide.run
2
2
3
+ import com.intellij.execution.DefaultExecutionResult
3
4
import com.intellij.execution.ExecutionException
4
- import com.intellij.execution.configurations.CommandLineState
5
+ import com.intellij.execution.ExecutionResult
6
+ import com.intellij.execution.Executor
5
7
import com.intellij.execution.configurations.PtyCommandLine
6
8
import com.intellij.execution.configurations.RunProfileState
7
9
import com.intellij.execution.process.KillableColoredProcessHandler
8
10
import com.intellij.execution.process.ProcessHandler
9
11
import com.intellij.execution.runners.ExecutionEnvironment
12
+ import com.intellij.execution.runners.ProgramRunner
10
13
import com.intellij.execution.util.ProgramParametersUtil
11
14
import com.intellij.openapi.application.readAction
12
15
import com.intellij.openapi.diagnostic.logger
@@ -15,15 +18,17 @@ import com.intellij.openapi.util.text.StringUtil
15
18
import com.intellij.openapi.vfs.LocalFileSystem
16
19
import com.intellij.plugin.powershell.lang.lsp.LSPInitMain
17
20
import com.intellij.plugin.powershell.lang.lsp.languagehost.PowerShellNotInstalled
21
+ import com.intellij.terminal.TerminalExecutionConsole
18
22
import kotlinx.coroutines.Dispatchers
19
23
import kotlinx.coroutines.withContext
20
24
import java.io.File
21
25
import java.nio.file.Path
22
26
import java.util.regex.Pattern
23
27
import kotlin.io.path.Path
24
28
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 {
27
32
28
33
lateinit var workingDirectory: Path
29
34
suspend fun prepareExecution () {
@@ -39,7 +44,7 @@ class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellR
39
44
)
40
45
}
41
46
42
- override fun startProcess (): ProcessHandler {
47
+ private fun startProcess (): ProcessHandler {
43
48
try {
44
49
val command = buildCommand(
45
50
runConfiguration.executablePath ? : LSPInitMain .getInstance().getPowerShellExecutable(),
@@ -48,6 +53,7 @@ class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellR
48
53
runConfiguration.scriptParameters
49
54
)
50
55
val commandLine = PtyCommandLine (command)
56
+ .withConsoleMode(false )
51
57
.withWorkDirectory(workingDirectory.toString())
52
58
53
59
runConfiguration.environmentVariables.configureCommandLine(commandLine, true )
@@ -90,6 +96,12 @@ class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellR
90
96
}
91
97
return commandString
92
98
}
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
+ }
93
105
}
94
106
95
107
private val logger = logger<PowerShellScriptCommandLineState >()
0 commit comments