@@ -37,8 +37,7 @@ import { TerminalShellType } from '../../common/terminal/types';
37
37
import { OSType } from '../../common/utils/platform' ;
38
38
import { normCase } from '../../common/platform/fs-paths' ;
39
39
import { PythonEnvType } from '../../pythonEnvironments/base/info' ;
40
- import { ITerminalEnvVarCollectionService } from '../types' ;
41
- import { ShellIntegrationShells } from './shellIntegration' ;
40
+ import { IShellIntegrationService , ITerminalEnvVarCollectionService } from '../types' ;
42
41
import { ProgressService } from '../../common/application/progressService' ;
43
42
44
43
@injectable ( )
@@ -80,6 +79,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
80
79
@inject ( IWorkspaceService ) private workspaceService : IWorkspaceService ,
81
80
@inject ( IConfigurationService ) private readonly configurationService : IConfigurationService ,
82
81
@inject ( IPathUtils ) private readonly pathUtils : IPathUtils ,
82
+ @inject ( IShellIntegrationService ) private readonly shellIntegrationService : IShellIntegrationService ,
83
83
) {
84
84
this . separator = platform . osType === OSType . Windows ? ';' : ':' ;
85
85
this . progressService = new ProgressService ( this . shell ) ;
@@ -121,7 +121,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
121
121
this . disposables ,
122
122
) ;
123
123
const { shell } = this . applicationEnvironment ;
124
- const isActive = this . isShellIntegrationActive ( shell ) ;
124
+ const isActive = this . shellIntegrationService . isWorking ( shell ) ;
125
125
const shellType = identifyShellFromShellPath ( shell ) ;
126
126
if ( ! isActive && shellType !== TerminalShellType . commandPrompt ) {
127
127
traceWarn ( `Shell integration is not active, environment activated maybe overriden by the shell.` ) ;
@@ -184,7 +184,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
184
184
185
185
// PS1 in some cases is a shell variable (not an env variable) so "env" might not contain it, calculate it in that case.
186
186
env . PS1 = await this . getPS1 ( shell , resource , env ) ;
187
- const prependOptions = this . getPrependOptions ( shell ) ;
187
+ const prependOptions = await this . getPrependOptions ( shell ) ;
188
188
189
189
// Clear any previously set env vars from collection
190
190
envVarCollection . clear ( ) ;
@@ -277,7 +277,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
277
277
// PS1 should be set but no PS1 was set.
278
278
return ;
279
279
}
280
- const config = this . isShellIntegrationActive ( shell ) ;
280
+ const config = await this . shellIntegrationService . isWorking ( shell ) ;
281
281
if ( ! config ) {
282
282
traceVerbose ( 'PS1 is not set when shell integration is disabled.' ) ;
283
283
return ;
@@ -332,8 +332,8 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
332
332
}
333
333
}
334
334
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 ) ;
337
337
// Ideally we would want to prepend exactly once, either at shell integration or process creation.
338
338
// TODO: Stop prepending altogether once https://github.com/microsoft/vscode/issues/145234 is available.
339
339
return isActive
@@ -347,21 +347,6 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
347
347
} ;
348
348
}
349
349
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
-
365
350
private getEnvironmentVariableCollection ( scope : EnvironmentVariableScope = { } ) {
366
351
const envVarCollection = this . context . environmentVariableCollection as GlobalEnvironmentVariableCollection ;
367
352
return envVarCollection . getScoped ( scope ) ;
0 commit comments