@@ -2,6 +2,7 @@ import * as fsapi from 'fs-extra';
22import * as path from 'path' ;
33import { Disposable , EventEmitter , ProgressLocation , Terminal , TerminalOptions , Uri } from 'vscode' ;
44import { PythonEnvironment , PythonEnvironmentApi , PythonProject , PythonTerminalCreateOptions } from '../../api' ;
5+ import { ActivationStrings } from '../../common/localize' ;
56import { traceInfo , traceVerbose } from '../../common/logging' ;
67import {
78 createTerminal ,
@@ -23,7 +24,15 @@ import {
2324 TerminalActivationInternal ,
2425 TerminalEnvironment ,
2526} from './terminalActivationState' ;
26- import { AutoActivationType , getAutoActivationType , getEnvironmentForTerminal , waitForShellIntegration } from './utils' ;
27+ import {
28+ ACT_TYPE_COMMAND ,
29+ ACT_TYPE_OFF ,
30+ ACT_TYPE_SHELL ,
31+ AutoActivationType ,
32+ getAutoActivationType ,
33+ getEnvironmentForTerminal ,
34+ waitForShellIntegration ,
35+ } from './utils' ;
2736
2837export interface TerminalCreation {
2938 create ( environment : PythonEnvironment , options : PythonTerminalCreateOptions ) : Promise < Terminal > ;
@@ -108,7 +117,7 @@ export class TerminalManagerImpl implements TerminalManager {
108117 onDidChangeConfiguration ( async ( e ) => {
109118 if ( e . affectsConfiguration ( 'python-envs.terminal.autoActivationType' ) ) {
110119 const actType = getAutoActivationType ( ) ;
111- if ( actType === 'shellStartup' ) {
120+ if ( actType === ACT_TYPE_SHELL ) {
112121 traceInfo ( `Auto activation type changed to ${ actType } ` ) ;
113122 const shells = new Set (
114123 terminals ( )
@@ -178,10 +187,10 @@ export class TerminalManagerImpl implements TerminalManager {
178187 let isSetup = this . shellSetup . get ( shellType ) ;
179188 if ( isSetup === true ) {
180189 traceVerbose ( `Shell profile for ${ shellType } is already setup.` ) ;
181- return 'shellStartup' ;
190+ return ACT_TYPE_SHELL ;
182191 } else if ( isSetup === false ) {
183192 traceVerbose ( `Shell profile for ${ shellType } is not set up, using command fallback.` ) ;
184- return 'command' ;
193+ return ACT_TYPE_COMMAND ;
185194 }
186195 }
187196
@@ -197,25 +206,25 @@ export class TerminalManagerImpl implements TerminalManager {
197206 await this . handleSetupCheck ( shellType ) ;
198207
199208 // Check again after the setup check.
200- return this . getShellActivationType ( shellType ) ?? 'command' ;
209+ return this . getShellActivationType ( shellType ) ?? ACT_TYPE_COMMAND ;
201210 }
202211 traceInfo ( `Shell startup not supported for ${ shellType } , using command activation as fallback` ) ;
203- return 'command' ;
212+ return ACT_TYPE_COMMAND ;
204213 }
205214
206215 private async autoActivateOnTerminalOpen ( terminal : Terminal , environment : PythonEnvironment ) : Promise < void > {
207216 let actType = getAutoActivationType ( ) ;
208217 const shellType = identifyTerminalShell ( terminal ) ;
209- if ( actType === 'shellStartup' ) {
218+ if ( actType === ACT_TYPE_SHELL ) {
210219 actType = await this . getEffectiveActivationType ( shellType ) ;
211220 }
212221
213- if ( actType === 'command' ) {
222+ if ( actType === ACT_TYPE_COMMAND ) {
214223 if ( isActivatableEnvironment ( environment ) ) {
215224 await withProgress (
216225 {
217226 location : ProgressLocation . Window ,
218- title : `Activating environment : ${ environment . environmentPath . fsPath } ` ,
227+ title : `${ ActivationStrings . activatingEnvironment } : ${ environment . environmentPath . fsPath } ` ,
219228 } ,
220229 async ( ) => {
221230 await waitForShellIntegration ( terminal ) ;
@@ -225,9 +234,9 @@ export class TerminalManagerImpl implements TerminalManager {
225234 } else {
226235 traceVerbose ( `Environment ${ environment . environmentPath . fsPath } is not activatable` ) ;
227236 }
228- } else if ( actType === 'off' ) {
237+ } else if ( actType === ACT_TYPE_OFF ) {
229238 traceInfo ( `"python-envs.terminal.autoActivationType" is set to "${ actType } ", skipping auto activation` ) ;
230- } else if ( actType === 'shellStartup' ) {
239+ } else if ( actType === ACT_TYPE_SHELL ) {
231240 traceInfo (
232241 `"python-envs.terminal.autoActivationType" is set to "${ actType } ", terminal should be activated by shell startup script` ,
233242 ) ;
@@ -237,7 +246,7 @@ export class TerminalManagerImpl implements TerminalManager {
237246 public async create ( environment : PythonEnvironment , options : PythonTerminalCreateOptions ) : Promise < Terminal > {
238247 const autoActType = getAutoActivationType ( ) ;
239248 let envVars = options . env ;
240- if ( autoActType === 'shellStartup' ) {
249+ if ( autoActType === ACT_TYPE_SHELL ) {
241250 const vars = await Promise . all ( this . startupEnvProviders . map ( ( p ) => p . getEnvVariables ( environment ) ) ) ;
242251
243252 vars . forEach ( ( varMap ) => {
@@ -249,6 +258,7 @@ export class TerminalManagerImpl implements TerminalManager {
249258 } ) ;
250259 }
251260
261+ // Uncomment the code line below after the issue is resolved:
252262 // https://github.com/microsoft/vscode-python-environments/issues/172
253263 // const name = options.name ?? `Python: ${environment.displayName}`;
254264 const newTerminal = createTerminal ( {
@@ -266,7 +276,7 @@ export class TerminalManagerImpl implements TerminalManager {
266276 isTransient : options . isTransient ,
267277 } ) ;
268278
269- if ( autoActType === 'command' ) {
279+ if ( autoActType === ACT_TYPE_COMMAND ) {
270280 if ( options . disableActivation ) {
271281 this . skipActivationOnOpen . add ( newTerminal ) ;
272282 return newTerminal ;
@@ -360,9 +370,9 @@ export class TerminalManagerImpl implements TerminalManager {
360370
361371 public async initialize ( api : PythonEnvironmentApi ) : Promise < void > {
362372 const actType = getAutoActivationType ( ) ;
363- if ( actType === 'command' ) {
373+ if ( actType === ACT_TYPE_COMMAND ) {
364374 await Promise . all ( terminals ( ) . map ( async ( t ) => this . activateUsingCommand ( api , t ) ) ) ;
365- } else if ( actType === 'shellStartup' ) {
375+ } else if ( actType === ACT_TYPE_SHELL ) {
366376 const shells = new Set (
367377 terminals ( )
368378 . map ( ( t ) => identifyTerminalShell ( t ) )
0 commit comments