Skip to content

Commit

Permalink
FEAT: force to use cmd on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
qtxie committed Aug 5, 2022
1 parent 7dbbaf3 commit e64d3d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -19,15 +23,15 @@ 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.

```
"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:

Expand Down
22 changes: 13 additions & 9 deletions src/commandsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e64d3d0

Please sign in to comment.