From e64d3d055f839508a1cb90fd0c3b485b19836bb5 Mon Sep 17 00:00:00 2001 From: Xie Qingtian Date: Fri, 5 Aug 2022 12:24:59 +0800 Subject: [PATCH] FEAT: force to use cmd on Windows. --- README.md | 10 +++++++--- src/commandsProvider.ts | 22 +++++++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 48bb3cd..9a80d8b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,11 @@ An extension with rich support for the [Red Programming language](https://www.re ## Settings -To enable features like IntelliSense, you need to configure the path to the Red binaries in the `Settings`. +### Set the Red binaries + +To enable features like IntelliSense, you need to configure the path to the [Red binaries](https://www.red-lang.org/p/download.html) in the `Settings`. + +There are two ways to do it. Details are as follows. --- **NOTE** @@ -19,7 +23,7 @@ Restart the VS Code to take effect after changing the `Settings`. --- -### Set the search path of the red binaries +### 1. Set the search path of the red binaries Download the [Red binaries](https://www.red-lang.org/p/download.html) to a local folder, then set the `red.redDir` to it. The plugin will use the latest one according to the filename. @@ -27,7 +31,7 @@ Download the [Red binaries](https://www.red-lang.org/p/download.html) to a local "red.redDir": "D:/Tools/Red/" ``` -### Set the full path of the red binaries +### 2. Set the full path of the red binaries If you want to use a specified version of Red binaries, use the following settings: diff --git a/src/commandsProvider.ts b/src/commandsProvider.ts index ce32365..b9083c3 100644 --- a/src/commandsProvider.ts +++ b/src/commandsProvider.ts @@ -33,27 +33,31 @@ function normalFile(value: string): string { return value.replace(/\\/g, '/'); } +function createTerm(name: string) { + if (process.platform === 'win32') { + return vscode.window.createTerminal(name, 'cmd'); + } else { + return vscode.window.createTerminal(name); + } +} + function execCommand(command: string, args: string) { + const termName = 'Red'; let text: string = ""; for (let t of vscode.window.terminals) { - if (t.name === 'Red') { + if (t.name === termName) { terminal = t; break; } } - terminal = terminal ? terminal : vscode.window.createTerminal('Red'); + terminal = terminal ? terminal : createTerm(termName); if (terminal && terminal.exitStatus) { // killed by the user terminal.dispose(); - terminal = vscode.window.createTerminal('Red'); - } - if (process.platform === 'win32') { - const activeTerm = vscode.window.activeTerminal; - if (activeTerm !== undefined && activeTerm.name !== 'bash') { - text = "cmd --% /c \""; - } + terminal = createTerm(termName); } + text = text + "\"" + command + "\""; text = text + " " + args; terminal.sendText(text);