Skip to content

Commit 704cd06

Browse files
committed
src/goEnvironmentStatus.ts: use vscode.env.shell to determine shell type
When the callback for vscode.window.onDidOpenTerminal is called terminal.name is typically unset and can change during launch. The API for vscode.env.shell has stabilized so we can use that value instead. Removed support for windows shells, as this code path only runs on macOS. Fixes #2283. Change-Id: I62517812ddc194393ed36c89dc6fd13f4ef77b71 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/412314 Reviewed-by: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Jamal Carvalho <[email protected]> TryBot-Result: kokoro <[email protected]>
1 parent c31bc21 commit 704cd06

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/goEnvironmentStatus.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,17 +374,13 @@ export async function updateIntegratedTerminal(terminal: vscode.Terminal): Promi
374374

375375
// append the goroot to the beginning of the PATH so it takes precedence
376376
// TODO: add support for more terminal names
377-
// this assumes all non-windows shells are bash-like.
378-
if (terminal.name.toLowerCase() === 'cmd') {
379-
terminal.sendText(`set PATH=${gorootBin};%Path%`, true);
380-
terminal.sendText('cls');
381-
} else if (['powershell', 'pwsh'].includes(terminal.name.toLowerCase())) {
377+
if (vscode.env.shell.search(/(powershell|pwsh)$/i) !== -1) {
382378
terminal.sendText(`$env:Path="${gorootBin};$env:Path"`, true);
383379
terminal.sendText('clear');
384-
} else if (terminal.name.toLowerCase() === 'fish') {
380+
} else if (vscode.env.shell.search(/fish$/i) !== -1) {
385381
terminal.sendText(`set -gx PATH ${gorootBin} $PATH`);
386382
terminal.sendText('clear');
387-
} else if (['bash', 'sh', 'zsh', 'ksh'].includes(terminal.name.toLowerCase())) {
383+
} else if (vscode.env.shell.search(/\/(bash|sh|zsh|ksh)$/i) !== -1) {
388384
terminal.sendText(`export PATH=${gorootBin}:$PATH`, true);
389385
terminal.sendText('clear');
390386
}

0 commit comments

Comments
 (0)