@@ -2,6 +2,7 @@ import * as fsapi from 'fs-extra';
2
2
import * as path from 'path' ;
3
3
import { Disposable , EventEmitter , ProgressLocation , Terminal , TerminalOptions , Uri } from 'vscode' ;
4
4
import { PythonEnvironment , PythonEnvironmentApi , PythonProject , PythonTerminalCreateOptions } from '../../api' ;
5
+ import { ActivationStrings } from '../../common/localize' ;
5
6
import { traceInfo , traceVerbose } from '../../common/logging' ;
6
7
import {
7
8
createTerminal ,
@@ -23,7 +24,15 @@ import {
23
24
TerminalActivationInternal ,
24
25
TerminalEnvironment ,
25
26
} 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' ;
27
36
28
37
export interface TerminalCreation {
29
38
create ( environment : PythonEnvironment , options : PythonTerminalCreateOptions ) : Promise < Terminal > ;
@@ -108,7 +117,7 @@ export class TerminalManagerImpl implements TerminalManager {
108
117
onDidChangeConfiguration ( async ( e ) => {
109
118
if ( e . affectsConfiguration ( 'python-envs.terminal.autoActivationType' ) ) {
110
119
const actType = getAutoActivationType ( ) ;
111
- if ( actType === 'shellStartup' ) {
120
+ if ( actType === ACT_TYPE_SHELL ) {
112
121
traceInfo ( `Auto activation type changed to ${ actType } ` ) ;
113
122
const shells = new Set (
114
123
terminals ( )
@@ -178,10 +187,10 @@ export class TerminalManagerImpl implements TerminalManager {
178
187
let isSetup = this . shellSetup . get ( shellType ) ;
179
188
if ( isSetup === true ) {
180
189
traceVerbose ( `Shell profile for ${ shellType } is already setup.` ) ;
181
- return 'shellStartup' ;
190
+ return ACT_TYPE_SHELL ;
182
191
} else if ( isSetup === false ) {
183
192
traceVerbose ( `Shell profile for ${ shellType } is not set up, using command fallback.` ) ;
184
- return 'command' ;
193
+ return ACT_TYPE_COMMAND ;
185
194
}
186
195
}
187
196
@@ -197,25 +206,25 @@ export class TerminalManagerImpl implements TerminalManager {
197
206
await this . handleSetupCheck ( shellType ) ;
198
207
199
208
// Check again after the setup check.
200
- return this . getShellActivationType ( shellType ) ?? 'command' ;
209
+ return this . getShellActivationType ( shellType ) ?? ACT_TYPE_COMMAND ;
201
210
}
202
211
traceInfo ( `Shell startup not supported for ${ shellType } , using command activation as fallback` ) ;
203
- return 'command' ;
212
+ return ACT_TYPE_COMMAND ;
204
213
}
205
214
206
215
private async autoActivateOnTerminalOpen ( terminal : Terminal , environment : PythonEnvironment ) : Promise < void > {
207
216
let actType = getAutoActivationType ( ) ;
208
217
const shellType = identifyTerminalShell ( terminal ) ;
209
- if ( actType === 'shellStartup' ) {
218
+ if ( actType === ACT_TYPE_SHELL ) {
210
219
actType = await this . getEffectiveActivationType ( shellType ) ;
211
220
}
212
221
213
- if ( actType === 'command' ) {
222
+ if ( actType === ACT_TYPE_COMMAND ) {
214
223
if ( isActivatableEnvironment ( environment ) ) {
215
224
await withProgress (
216
225
{
217
226
location : ProgressLocation . Window ,
218
- title : `Activating environment : ${ environment . environmentPath . fsPath } ` ,
227
+ title : `${ ActivationStrings . activatingEnvironment } : ${ environment . environmentPath . fsPath } ` ,
219
228
} ,
220
229
async ( ) => {
221
230
await waitForShellIntegration ( terminal ) ;
@@ -225,9 +234,9 @@ export class TerminalManagerImpl implements TerminalManager {
225
234
} else {
226
235
traceVerbose ( `Environment ${ environment . environmentPath . fsPath } is not activatable` ) ;
227
236
}
228
- } else if ( actType === 'off' ) {
237
+ } else if ( actType === ACT_TYPE_OFF ) {
229
238
traceInfo ( `"python-envs.terminal.autoActivationType" is set to "${ actType } ", skipping auto activation` ) ;
230
- } else if ( actType === 'shellStartup' ) {
239
+ } else if ( actType === ACT_TYPE_SHELL ) {
231
240
traceInfo (
232
241
`"python-envs.terminal.autoActivationType" is set to "${ actType } ", terminal should be activated by shell startup script` ,
233
242
) ;
@@ -237,7 +246,7 @@ export class TerminalManagerImpl implements TerminalManager {
237
246
public async create ( environment : PythonEnvironment , options : PythonTerminalCreateOptions ) : Promise < Terminal > {
238
247
const autoActType = getAutoActivationType ( ) ;
239
248
let envVars = options . env ;
240
- if ( autoActType === 'shellStartup' ) {
249
+ if ( autoActType === ACT_TYPE_SHELL ) {
241
250
const vars = await Promise . all ( this . startupEnvProviders . map ( ( p ) => p . getEnvVariables ( environment ) ) ) ;
242
251
243
252
vars . forEach ( ( varMap ) => {
@@ -249,6 +258,7 @@ export class TerminalManagerImpl implements TerminalManager {
249
258
} ) ;
250
259
}
251
260
261
+ // Uncomment the code line below after the issue is resolved:
252
262
// https://github.com/microsoft/vscode-python-environments/issues/172
253
263
// const name = options.name ?? `Python: ${environment.displayName}`;
254
264
const newTerminal = createTerminal ( {
@@ -266,7 +276,7 @@ export class TerminalManagerImpl implements TerminalManager {
266
276
isTransient : options . isTransient ,
267
277
} ) ;
268
278
269
- if ( autoActType === 'command' ) {
279
+ if ( autoActType === ACT_TYPE_COMMAND ) {
270
280
if ( options . disableActivation ) {
271
281
this . skipActivationOnOpen . add ( newTerminal ) ;
272
282
return newTerminal ;
@@ -360,9 +370,9 @@ export class TerminalManagerImpl implements TerminalManager {
360
370
361
371
public async initialize ( api : PythonEnvironmentApi ) : Promise < void > {
362
372
const actType = getAutoActivationType ( ) ;
363
- if ( actType === 'command' ) {
373
+ if ( actType === ACT_TYPE_COMMAND ) {
364
374
await Promise . all ( terminals ( ) . map ( async ( t ) => this . activateUsingCommand ( api , t ) ) ) ;
365
- } else if ( actType === 'shellStartup' ) {
375
+ } else if ( actType === ACT_TYPE_SHELL ) {
366
376
const shells = new Set (
367
377
terminals ( )
368
378
. map ( ( t ) => identifyTerminalShell ( t ) )
0 commit comments