Skip to content

Commit 9b05c67

Browse files
authored
Merge branch 'main' into bubbly-bats
2 parents 69a1020 + 95761d9 commit 9b05c67

11 files changed

Lines changed: 88 additions & 39 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-python-envs",
33
"displayName": "Python Environments",
44
"description": "Provides a unified python environment experience",
5-
"version": "1.2.0",
5+
"version": "1.3.0",
66
"publisher": "ms-python",
77
"preview": true,
88
"engines": {

src/features/execution/execUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function quoteArg(arg: string): string {
1+
export function quoteArg(arg: string): string {
22
if (arg.indexOf(' ') >= 0 && !(arg.startsWith('"') && arg.endsWith('"'))) {
33
return `"${arg}"`;
44
}

src/features/execution/runAsTask.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {
88
Uri,
99
WorkspaceFolder,
1010
} from 'vscode';
11-
import { PythonTaskExecutionOptions } from '../../api';
12-
import { getWorkspaceFolder } from '../../common/workspace.apis';
13-
import { PythonEnvironment } from '../../api';
11+
import { PythonEnvironment, PythonTaskExecutionOptions } from '../../api';
1412
import { executeTask } from '../../common/tasks.apis';
13+
import { getWorkspaceFolder } from '../../common/workspace.apis';
14+
import { quoteArg } from './execUtils';
1515

1616
function getWorkspaceFolderOrDefault(uri?: Uri): WorkspaceFolder | TaskScope {
1717
const workspace = uri ? getWorkspaceFolder(uri) : undefined;
@@ -25,8 +25,8 @@ export async function runAsTask(
2525
): Promise<TaskExecution> {
2626
const workspace: WorkspaceFolder | TaskScope = getWorkspaceFolderOrDefault(options.project?.uri);
2727

28-
const executable =
29-
environment.execInfo?.activatedRun?.executable ?? environment.execInfo?.run.executable ?? 'python';
28+
let executable = environment.execInfo?.activatedRun?.executable ?? environment.execInfo?.run.executable ?? 'python';
29+
executable = quoteArg(executable);
3030
const args = environment.execInfo?.activatedRun?.args ?? environment.execInfo?.run.args ?? [];
3131
const allArgs = [...args, ...options.args];
3232

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const BASH_ENV_KEY = 'VSCODE_BASH_ACTIVATE';
22
export const ZSH_ENV_KEY = 'VSCODE_ZSH_ACTIVATE';
3-
export const BASH_SCRIPT_VERSION = '0.1.0';
3+
export const BASH_SCRIPT_VERSION = '0.1.1';

src/features/terminal/shells/bash/bashStartup.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ function getActivationContent(key: string): string {
4848
const lineSep = '\n';
4949
return [
5050
`# version: ${BASH_SCRIPT_VERSION}`,
51-
`if [ -n "$${key}" ] && [ "$TERM_PROGRAM" = "vscode" ]; then`,
52-
` eval "$${key}" || true`,
53-
'fi',
51+
`if [ -z "$VSCODE_PYTHON_AUTOACTIVATE_GUARD" ]; then`,
52+
` export VSCODE_PYTHON_AUTOACTIVATE_GUARD=1`,
53+
` if [ -n "$${key}" ] && [ "$TERM_PROGRAM" = "vscode" ]; then`,
54+
` eval "$${key}" || true`,
55+
` fi`,
56+
`fi`,
5457
].join(lineSep);
5558
}
5659

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export const FISH_ENV_KEY = 'VSCODE_FISH_ACTIVATE';
2-
export const FISH_SCRIPT_VERSION = '0.1.0';
2+
export const FISH_SCRIPT_VERSION = '0.1.1';

src/features/terminal/shells/fish/fishStartup.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ function getActivationContent(key: string): string {
3434
const lineSep = '\n';
3535
return [
3636
`# version: ${FISH_SCRIPT_VERSION}`,
37-
`if test "$TERM_PROGRAM" = "vscode"; and set -q ${key}`,
38-
` eval $${key}`,
39-
'end',
37+
`if not set -q VSCODE_PYTHON_AUTOACTIVATE_GUARD`,
38+
` set -gx VSCODE_PYTHON_AUTOACTIVATE_GUARD 1`,
39+
` if test "$TERM_PROGRAM" = "vscode"; and set -q ${key}`,
40+
` eval $${key}`,
41+
` end`,
42+
`end`,
4043
].join(lineSep);
4144
}
4245

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export const POWERSHELL_ENV_KEY = 'VSCODE_PWSH_ACTIVATE';
2-
export const PWSH_SCRIPT_VERSION = '0.1.0';
2+
export const PWSH_SCRIPT_VERSION = '0.1.1';

src/features/terminal/shells/pwsh/pwshStartup.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,14 @@ function getActivationContent(): string {
113113
const lineSep = isWindows() ? '\r\n' : '\n';
114114
const activationContent = [
115115
`#version: ${PWSH_SCRIPT_VERSION}`,
116-
`if (($env:TERM_PROGRAM -eq 'vscode') -and ($null -ne $env:${POWERSHELL_ENV_KEY})) {`,
117-
' try {',
118-
` Invoke-Expression $env:${POWERSHELL_ENV_KEY}`,
119-
' } catch {',
120-
` Write-Error "Failed to activate Python environment: $_" -ErrorAction Continue`,
116+
`if (-not $env:VSCODE_PYTHON_AUTOACTIVATE_GUARD) {`,
117+
` $env:VSCODE_PYTHON_AUTOACTIVATE_GUARD = '1'`,
118+
` if (($env:TERM_PROGRAM -eq 'vscode') -and ($null -ne $env:${POWERSHELL_ENV_KEY})) {`,
119+
' try {',
120+
` Invoke-Expression $env:${POWERSHELL_ENV_KEY}`,
121+
' } catch {',
122+
` Write-Error "Failed to activate Python environment: $_" -ErrorAction Continue`,
123+
' }',
121124
' }',
122125
'}',
123126
].join(lineSep);

0 commit comments

Comments
 (0)