Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit 649b865

Browse files
authored
fix: use '&' when sending commands using sendtext to powershell (#262)
Fixes microsoft/vscode-python-environments#257
1 parent aed4e53 commit 649b865

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/features/terminal/runInTerminal.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { PythonEnvironment, PythonTerminalExecutionOptions } from '../../api';
33
import { onDidEndTerminalShellExecution } from '../../common/window.apis';
44
import { createDeferred } from '../../common/utils/deferred';
55
import { quoteArgs } from '../execution/execUtils';
6+
import { identifyTerminalShell } from '../common/shellDetector';
67

78
export async function runInTerminal(
89
environment: PythonEnvironment,
@@ -28,9 +29,14 @@ export async function runInTerminal(
2829
}
2930
});
3031
execution = terminal.shellIntegration.executeCommand(executable, allArgs);
31-
return deferred.promise;
32+
await deferred.promise;
3233
} else {
33-
const text = quoteArgs([executable, ...allArgs]).join(' ');
34+
const shellType = identifyTerminalShell(terminal);
35+
let text = quoteArgs([executable, ...allArgs]).join(' ');
36+
if (shellType === 'pwsh' && !text.startsWith('&')) {
37+
// PowerShell requires commands to be prefixed with '&' to run them.
38+
text = `& ${text}`;
39+
}
3440
terminal.sendText(`${text}\n`);
3541
}
3642
}

0 commit comments

Comments
 (0)