File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change 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 }
Original file line number Diff line number Diff 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' ;
1412import { executeTask } from '../../common/tasks.apis' ;
13+ import { getWorkspaceFolder } from '../../common/workspace.apis' ;
14+ import { quoteArg } from './execUtils' ;
1515
1616function 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
Original file line number Diff line number Diff line change 11export const BASH_ENV_KEY = 'VSCODE_BASH_ACTIVATE' ;
22export 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 ' ;
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 11export 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 ' ;
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 11export 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 ' ;
Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments