@@ -5,14 +5,14 @@ import '../../common/extensions';
55
66import { inject , injectable } from 'inversify' ;
77
8- import { IWorkspaceService } from '../../common/application/types' ;
8+ import { IApplicationShell , IWorkspaceService } from '../../common/application/types' ;
99import { PYTHON_WARNINGS } from '../../common/constants' ;
1010import { IPlatformService } from '../../common/platform/types' ;
1111import * as internalScripts from '../../common/process/internal/scripts' ;
1212import { ExecutionResult , IProcessServiceFactory } from '../../common/process/types' ;
1313import { ITerminalHelper , TerminalShellType } from '../../common/terminal/types' ;
1414import { ICurrentProcess , IDisposable , IExtensionContext , Resource } from '../../common/types' ;
15- import { sleep } from '../../common/utils/async' ;
15+ import { createDeferred , Deferred , sleep } from '../../common/utils/async' ;
1616import { InMemoryCache } from '../../common/utils/cacheUtils' ;
1717import { OSType } from '../../common/utils/platform' ;
1818import { IEnvironmentVariablesProvider } from '../../common/variables/types' ;
@@ -32,6 +32,8 @@ import {
3232} from '../../logging' ;
3333import { Conda } from '../../pythonEnvironments/common/environmentManagers/conda' ;
3434import { StopWatch } from '../../common/utils/stopWatch' ;
35+ import { Interpreters } from '../../common/utils/localize' ;
36+ import { ProgressLocation , ProgressOptions } from 'vscode' ;
3537
3638const ENVIRONMENT_PREFIX = 'e8b39361-0157-4923-80e1-22d70d46dee6' ;
3739const CACHE_DURATION = 10 * 60 * 1000 ;
@@ -102,6 +104,7 @@ export class EnvironmentActivationServiceCache {
102104@injectable ( )
103105export class EnvironmentActivationService implements IEnvironmentActivationService , IDisposable {
104106 private readonly disposables : IDisposable [ ] = [ ] ;
107+ private deferred : Deferred < void > | undefined ;
105108 private previousEnvVars = process . env ;
106109 private readonly activatedEnvVariablesCache = new EnvironmentActivationServiceCache ( ) ;
107110 constructor (
@@ -113,6 +116,7 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi
113116 @inject ( IInterpreterService ) private interpreterService : IInterpreterService ,
114117 @inject ( IEnvironmentVariablesProvider ) private readonly envVarsService : IEnvironmentVariablesProvider ,
115118 @inject ( IExtensionContext ) private context : IExtensionContext ,
119+ @inject ( IApplicationShell ) private shell : IApplicationShell ,
116120 ) {
117121 this . envVarsService . onDidEnvironmentVariablesChange (
118122 ( ) => this . activatedEnvVariablesCache . clear ( ) ,
@@ -122,8 +126,10 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi
122126
123127 this . interpreterService . onDidChangeInterpreter (
124128 async ( resource ) => {
129+ this . showProgress ( ) ;
125130 this . activatedEnvVariablesCache . clear ( ) ;
126131 await this . initializeEnvironmentCollection ( resource ) ;
132+ this . hideProgress ( ) ;
127133 } ,
128134 this ,
129135 this . disposables ,
@@ -353,4 +359,30 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi
353359 }
354360 }
355361 }
362+
363+ @traceDecoratorVerbose ( 'Display activating terminals' )
364+ private showProgress ( ) : void {
365+ if ( ! this . deferred ) {
366+ this . createProgress ( ) ;
367+ }
368+ }
369+
370+ @traceDecoratorVerbose ( 'Hide activating terminals' )
371+ private hideProgress ( ) : void {
372+ if ( this . deferred ) {
373+ this . deferred . resolve ( ) ;
374+ this . deferred = undefined ;
375+ }
376+ }
377+
378+ private createProgress ( ) {
379+ const progressOptions : ProgressOptions = {
380+ location : ProgressLocation . Window ,
381+ title : Interpreters . activatingTerminals ,
382+ } ;
383+ this . shell . withProgress ( progressOptions , ( ) => {
384+ this . deferred = createDeferred ( ) ;
385+ return this . deferred . promise ;
386+ } ) ;
387+ }
356388}
0 commit comments