From 327e568da7efbb6e5df7f3cb95d4919afc98f570 Mon Sep 17 00:00:00 2001 From: Pavel Karateev Date: Sat, 7 Oct 2023 13:43:07 +0200 Subject: [PATCH] Fix REPL Switch from the deprecated `TerminalProcessOptions` to `ShellStartupOptions` new API --- .../repl/MicroPythonReplManager.kt | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/jetbrains/micropython/repl/MicroPythonReplManager.kt b/src/main/kotlin/com/jetbrains/micropython/repl/MicroPythonReplManager.kt index 0250f6b2..8309bd01 100644 --- a/src/main/kotlin/com/jetbrains/micropython/repl/MicroPythonReplManager.kt +++ b/src/main/kotlin/com/jetbrains/micropython/repl/MicroPythonReplManager.kt @@ -7,7 +7,7 @@ import com.jetbrains.micropython.settings.MicroPythonFacet import com.jetbrains.micropython.settings.microPythonFacet import com.pty4j.PtyProcess import org.jetbrains.plugins.terminal.LocalTerminalDirectRunner -import org.jetbrains.plugins.terminal.TerminalProcessOptions +import org.jetbrains.plugins.terminal.ShellStartupOptions interface CommsEventListener { fun onProcessStarted(ttyConnector: TtyConnector) @@ -45,13 +45,15 @@ class MicroPythonReplManager(module: Module) { return } + val initialShellCommand = mutableListOf( + facet.pythonPath!!, + "${MicroPythonFacet.scriptsPath}/microrepl.py", + devicePath + ) + val terminalRunner = object : LocalTerminalDirectRunner(currentModule.project) { override fun getInitialCommand(envs: MutableMap): MutableList { - return mutableListOf( - facet.pythonPath!!, - "${MicroPythonFacet.scriptsPath}/microrepl.py", - devicePath - ) + return initialShellCommand } fun getTtyConnector(process: PtyProcess): TtyConnector { @@ -60,8 +62,11 @@ class MicroPythonReplManager(module: Module) { } synchronized(this) { - val terminalOptions = TerminalProcessOptions(null, null, null) - val process = terminalRunner.createProcess(terminalOptions, null) + val terminalOptions = ShellStartupOptions.Builder() + .workingDirectory(devicePath) + .shellCommand(initialShellCommand) + .build() + val process = terminalRunner.createProcess(terminalOptions) val ttyConnector = terminalRunner.getTtyConnector(process) currentProcess = process