3
3
4
4
import { inject , injectable } from 'inversify' ;
5
5
import { Uri } from 'vscode' ;
6
+ import * as path from 'path' ;
6
7
import { IActiveResourceService , IApplicationShell , ITerminalManager } from '../../common/application/types' ;
7
8
import {
8
9
IConfigurationService ,
@@ -16,6 +17,7 @@ import { IExtensionSingleActivationService } from '../../activation/types';
16
17
import { ITerminalEnvVarCollectionService } from './types' ;
17
18
import { inTerminalEnvVarExperiment } from '../../common/experiments/helpers' ;
18
19
import { IInterpreterService } from '../contracts' ;
20
+ import { PythonEnvironment } from '../../pythonEnvironments/info' ;
19
21
20
22
export const terminalEnvCollectionPromptKey = 'TERMINAL_ENV_COLLECTION_PROMPT_KEY' ;
21
23
@@ -70,7 +72,7 @@ export class TerminalEnvVarCollectionPrompt implements IExtensionSingleActivatio
70
72
}
71
73
const prompts = [ Common . doNotShowAgain ] ;
72
74
const interpreter = await this . interpreterService . getActiveInterpreter ( resource ) ;
73
- const terminalPromptName = interpreter ?. envName ? ` ( ${ interpreter . envName } )` : '' ;
75
+ const terminalPromptName = getPromptName ( interpreter ) ;
74
76
const selection = await this . appShell . showInformationMessage (
75
77
Interpreters . terminalEnvVarCollectionPrompt . format ( terminalPromptName ) ,
76
78
...prompts ,
@@ -83,3 +85,16 @@ export class TerminalEnvVarCollectionPrompt implements IExtensionSingleActivatio
83
85
}
84
86
}
85
87
}
88
+
89
+ function getPromptName ( interpreter ?: PythonEnvironment ) {
90
+ if ( ! interpreter ) {
91
+ return '' ;
92
+ }
93
+ if ( interpreter . envName ) {
94
+ return ` "(${ interpreter . envName } )"` ;
95
+ }
96
+ if ( interpreter . envPath ) {
97
+ return ` "(${ path . basename ( interpreter . envPath ) } )"` ;
98
+ }
99
+ return '' ;
100
+ }
0 commit comments