From ec6c5412a4abb8a9e8fd9c712a27b5a8301afe0d Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Wed, 20 Sep 2023 19:59:02 +0200 Subject: [PATCH] Fixed custom terminal emulator not opening on windows --- .../gitnuro/terminal/WindowsTerminalProvider.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/terminal/WindowsTerminalProvider.kt b/src/main/kotlin/com/jetpackduba/gitnuro/terminal/WindowsTerminalProvider.kt index 470b5f0..6487adf 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/terminal/WindowsTerminalProvider.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/terminal/WindowsTerminalProvider.kt @@ -1,24 +1,29 @@ package com.jetpackduba.gitnuro.terminal import com.jetpackduba.gitnuro.managers.IShellManager +import java.io.File import javax.inject.Inject class WindowsTerminalProvider @Inject constructor( private val shellManager: IShellManager ) : ITerminalProvider { + private val powerShellEmulator = + TerminalEmulator("Powershell", "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe") + override fun getTerminalEmulators(): List { - return listOf( - // TODO powershell is the only terminal emulator supported until we add support for custom - TerminalEmulator("Powershell", "powershell.exe"), - ) + return listOf(powerShellEmulator) } override fun isTerminalInstalled(terminalEmulator: TerminalEmulator): Boolean { - // TODO how do we know if it's installed? We must check the output when trying to start an app that doesn't exist + // We don't care if it's not installed return true } override fun startTerminal(terminalEmulator: TerminalEmulator, repositoryPath: String) { - shellManager.runCommandInPath(listOf("cmd", "/c", "start", terminalEmulator.path), repositoryPath) + if (terminalEmulator == powerShellEmulator) { + shellManager.runCommandInPath(listOf("cmd", "/c", "start", terminalEmulator.path), repositoryPath) + } else { + shellManager.runCommandInPath(listOf("cmd", "/c", terminalEmulator.path), repositoryPath) + } } } \ No newline at end of file