From 9e69d4d350382b0a5faa52f3817ca0ee70318c6a Mon Sep 17 00:00:00 2001 From: Taoning Ge Date: Fri, 13 Jan 2023 16:16:51 +0800 Subject: [PATCH] Improve compatibility with Windows shell --- src/codeManager.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/codeManager.ts b/src/codeManager.ts index 3de6e2e..e352488 100644 --- a/src/codeManager.ts +++ b/src/codeManager.ts @@ -417,15 +417,17 @@ export class CodeManager implements vscode.Disposable { } private changeFilePathForBashOnWindows(command: string): string { - if (os.platform() === "win32") { - const windowsShell = vscode.env.shell; + const windowsShell = vscode.env.shell; + if (os.platform() === "win32" && windowsShell.toLowerCase().indexOf("powershell") === -1 && windowsShell.toLowerCase().indexOf("cmd") === -1) { const terminalRoot = this._config.get("terminalRoot"); - if (windowsShell && terminalRoot) { + if (windowsShell && windowsShell.toLowerCase().indexOf("wsl") > -1 && windowsShell.toLowerCase().indexOf("windows") > -1) { + command = command.replace(/([A-Za-z]):\\/g, this.replacer).replace(/\\/g, "/"); + } else if (windowsShell && windowsShell.toLowerCase().indexOf("bash") > -1 && windowsShell.toLowerCase().indexOf("windows") > -1) { + command = command.replace(/([A-Za-z]):\\/g, this.replacer).replace(/\\/g, "/"); + } else if (windowsShell && terminalRoot) { command = command .replace(/([A-Za-z]):\\/g, (match, p1) => `${terminalRoot}${p1.toLowerCase()}/`) .replace(/\\/g, "/"); - } else if (windowsShell && windowsShell.toLowerCase().indexOf("bash") > -1 && windowsShell.toLowerCase().indexOf("windows") > -1) { - command = command.replace(/([A-Za-z]):\\/g, this.replacer).replace(/\\/g, "/"); } } return command;