@@ -37,8 +37,7 @@ import { TerminalShellType } from '../../common/terminal/types';
3737import { OSType } from '../../common/utils/platform' ;
3838import { normCase } from '../../common/platform/fs-paths' ;
3939import { PythonEnvType } from '../../pythonEnvironments/base/info' ;
40- import { ITerminalEnvVarCollectionService } from '../types' ;
41- import { ShellIntegrationShells } from './shellIntegration' ;
40+ import { IShellIntegrationService , ITerminalEnvVarCollectionService } from '../types' ;
4241import { ProgressService } from '../../common/application/progressService' ;
4342
4443@injectable ( )
@@ -80,6 +79,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
8079 @inject ( IWorkspaceService ) private workspaceService : IWorkspaceService ,
8180 @inject ( IConfigurationService ) private readonly configurationService : IConfigurationService ,
8281 @inject ( IPathUtils ) private readonly pathUtils : IPathUtils ,
82+ @inject ( IShellIntegrationService ) private readonly shellIntegrationService : IShellIntegrationService ,
8383 ) {
8484 this . separator = platform . osType === OSType . Windows ? ';' : ':' ;
8585 this . progressService = new ProgressService ( this . shell ) ;
@@ -121,7 +121,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
121121 this . disposables ,
122122 ) ;
123123 const { shell } = this . applicationEnvironment ;
124- const isActive = this . isShellIntegrationActive ( shell ) ;
124+ const isActive = this . shellIntegrationService . isWorking ( shell ) ;
125125 const shellType = identifyShellFromShellPath ( shell ) ;
126126 if ( ! isActive && shellType !== TerminalShellType . commandPrompt ) {
127127 traceWarn ( `Shell integration is not active, environment activated maybe overriden by the shell.` ) ;
@@ -184,7 +184,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
184184
185185 // PS1 in some cases is a shell variable (not an env variable) so "env" might not contain it, calculate it in that case.
186186 env . PS1 = await this . getPS1 ( shell , resource , env ) ;
187- const prependOptions = this . getPrependOptions ( shell ) ;
187+ const prependOptions = await this . getPrependOptions ( shell ) ;
188188
189189 // Clear any previously set env vars from collection
190190 envVarCollection . clear ( ) ;
@@ -277,7 +277,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
277277 // PS1 should be set but no PS1 was set.
278278 return ;
279279 }
280- const config = this . isShellIntegrationActive ( shell ) ;
280+ const config = await this . shellIntegrationService . isWorking ( shell ) ;
281281 if ( ! config ) {
282282 traceVerbose ( 'PS1 is not set when shell integration is disabled.' ) ;
283283 return ;
@@ -332,8 +332,8 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
332332 }
333333 }
334334
335- private getPrependOptions ( shell : string ) : EnvironmentVariableMutatorOptions {
336- const isActive = this . isShellIntegrationActive ( shell ) ;
335+ private async getPrependOptions ( shell : string ) : Promise < EnvironmentVariableMutatorOptions > {
336+ const isActive = await this . shellIntegrationService . isWorking ( shell ) ;
337337 // Ideally we would want to prepend exactly once, either at shell integration or process creation.
338338 // TODO: Stop prepending altogether once https://github.com/microsoft/vscode/issues/145234 is available.
339339 return isActive
@@ -347,21 +347,6 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
347347 } ;
348348 }
349349
350- private isShellIntegrationActive ( shell : string ) : boolean {
351- const isEnabled = this . workspaceService
352- . getConfiguration ( 'terminal' )
353- . get < boolean > ( 'integrated.shellIntegration.enabled' ) ! ;
354- if ( isEnabled && ShellIntegrationShells . includes ( identifyShellFromShellPath ( shell ) ) ) {
355- // Unfortunately shell integration could still've failed in remote scenarios, we can't know for sure:
356- // https://code.visualstudio.com/docs/terminal/shell-integration#_automatic-script-injection
357- return true ;
358- }
359- if ( ! isEnabled ) {
360- traceVerbose ( 'Shell integrated is disabled in user settings.' ) ;
361- }
362- return false ;
363- }
364-
365350 private getEnvironmentVariableCollection ( scope : EnvironmentVariableScope = { } ) {
366351 const envVarCollection = this . context . environmentVariableCollection as GlobalEnvironmentVariableCollection ;
367352 return envVarCollection . getScoped ( scope ) ;
0 commit comments