File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 103103 " %python-envs.terminal.autoActivationType.off%"
104104 ],
105105 "scope" : " machine"
106+ },
107+ "python.terminal.injectEnvFile" : {
108+ "type" : " boolean" ,
109+ "description" : " Controls whether environment variables from .env files and python.envFile setting are injected into terminals" ,
110+ "default" : false ,
111+ "scope" : " resource"
106112 }
107113 }
108114 },
Original file line number Diff line number Diff line change @@ -109,14 +109,24 @@ export class TerminalEnvVarInjector implements Disposable {
109109 private async injectEnvironmentVariablesForWorkspace ( workspaceFolder : WorkspaceFolder ) : Promise < void > {
110110 const workspaceUri = workspaceFolder . uri ;
111111 try {
112- const envVars = await this . envVarManager . getEnvironmentVariables ( workspaceUri ) ;
113-
112+ // Check if environment variable injection is enabled
113+ const config = getConfiguration ( 'python' , workspaceUri ) ;
114+ const injectEnvFile = config . get < boolean > ( 'terminal.injectEnvFile' , false ) ;
115+
114116 // use scoped environment variable collection
115117 const envVarScope = this . getEnvironmentVariableCollectionScoped ( { workspaceFolder } ) ;
116118 envVarScope . clear ( ) ; // Clear existing variables for this workspace
117119
120+ if ( ! injectEnvFile ) {
121+ traceVerbose (
122+ `TerminalEnvVarInjector: Environment variable injection disabled for workspace: ${ workspaceUri . fsPath } ` ,
123+ ) ;
124+ return ; // Injection is disabled
125+ }
126+
127+ const envVars = await this . envVarManager . getEnvironmentVariables ( workspaceUri ) ;
128+
118129 // Track which .env file is being used for logging
119- const config = getConfiguration ( 'python' , workspaceUri ) ;
120130 const envFilePath = config . get < string > ( 'envFile' ) ;
121131 const resolvedEnvFilePath : string | undefined = envFilePath
122132 ? path . resolve ( resolveVariables ( envFilePath , workspaceUri ) )
You can’t perform that action at this time.
0 commit comments