@@ -89,6 +89,7 @@ export class SessionManager implements Middleware {
8989 private sessionDetails : IEditorServicesSessionDetails | undefined ;
9090 private sessionsFolder : vscode . Uri ;
9191 private sessionStatus : SessionStatus = SessionStatus . NotStarted ;
92+ private shellIntegrationEnabled = false ;
9293 private startCancellationTokenSource : vscode . CancellationTokenSource | undefined ;
9394 private suppressRestartPrompt = false ;
9495 private versionDetails : IPowerShellVersionDetails | undefined ;
@@ -109,6 +110,7 @@ export class SessionManager implements Middleware {
109110 // We have to override the scheme because it defaults to
110111 // 'vscode-userdata' which breaks UNC paths.
111112 this . sessionsFolder = vscode . Uri . joinPath ( extensionContext . globalStorageUri . with ( { scheme : "file" } ) , "sessions" ) ;
113+
112114 this . platformDetails = getPlatformDetails ( ) ;
113115 this . HostName = hostName ;
114116 this . DisplayName = displayName ;
@@ -189,6 +191,9 @@ export class SessionManager implements Middleware {
189191 // Migrate things.
190192 await this . migrateWhitespaceAroundPipeSetting ( ) ;
191193
194+ // Update non-PowerShell settings.
195+ this . shellIntegrationEnabled = vscode . workspace . getConfiguration ( "terminal.integrated.shellIntegration" ) . get < boolean > ( "enabled" ) ?? false ;
196+
192197 // Find the PowerShell executable to use for the server.
193198 this . PowerShellExeDetails = await this . findPowerShell ( ) ;
194199
@@ -447,19 +452,23 @@ export class SessionManager implements Middleware {
447452
448453 private async onConfigurationUpdated ( ) : Promise < void > {
449454 const settings = getSettings ( ) ;
455+ const shellIntegrationEnabled = vscode . workspace . getConfiguration ( "terminal.integrated.shellIntegration" ) . get < boolean > ( "enabled" ) ;
450456 this . logger . updateLogLevel ( settings . developer . editorServicesLogLevel ) ;
451457
452458 // Detect any setting changes that would affect the session.
453- if ( ! this . suppressRestartPrompt && this . sessionStatus === SessionStatus . Running &&
454- ( settings . cwd !== this . sessionSettings . cwd
455- || settings . powerShellDefaultVersion !== this . sessionSettings . powerShellDefaultVersion
456- || settings . developer . editorServicesLogLevel !== this . sessionSettings . developer . editorServicesLogLevel
457- || settings . developer . bundledModulesPath !== this . sessionSettings . developer . bundledModulesPath
458- || settings . developer . editorServicesWaitForDebugger !== this . sessionSettings . developer . editorServicesWaitForDebugger
459- || settings . developer . setExecutionPolicy !== this . sessionSettings . developer . setExecutionPolicy
460- || settings . integratedConsole . useLegacyReadLine !== this . sessionSettings . integratedConsole . useLegacyReadLine
461- || settings . integratedConsole . startInBackground !== this . sessionSettings . integratedConsole . startInBackground
462- || settings . integratedConsole . startLocation !== this . sessionSettings . integratedConsole . startLocation ) ) {
459+ if ( ! this . suppressRestartPrompt
460+ && this . sessionStatus === SessionStatus . Running
461+ && ( ( shellIntegrationEnabled !== this . shellIntegrationEnabled
462+ && ! settings . integratedConsole . startInBackground )
463+ || settings . cwd !== this . sessionSettings . cwd
464+ || settings . powerShellDefaultVersion !== this . sessionSettings . powerShellDefaultVersion
465+ || settings . developer . editorServicesLogLevel !== this . sessionSettings . developer . editorServicesLogLevel
466+ || settings . developer . bundledModulesPath !== this . sessionSettings . developer . bundledModulesPath
467+ || settings . developer . editorServicesWaitForDebugger !== this . sessionSettings . developer . editorServicesWaitForDebugger
468+ || settings . developer . setExecutionPolicy !== this . sessionSettings . developer . setExecutionPolicy
469+ || settings . integratedConsole . useLegacyReadLine !== this . sessionSettings . integratedConsole . useLegacyReadLine
470+ || settings . integratedConsole . startInBackground !== this . sessionSettings . integratedConsole . startInBackground
471+ || settings . integratedConsole . startLocation !== this . sessionSettings . integratedConsole . startLocation ) ) {
463472
464473 this . logger . writeVerbose ( "Settings changed, prompting to restart..." ) ;
465474 const response = await vscode . window . showInformationMessage (
@@ -610,10 +619,6 @@ export class SessionManager implements Middleware {
610619 } ) ;
611620 } ;
612621
613- // When Terminal Shell Integration is enabled, we pass the path to the script that the server should execute.
614- // Passing an empty string implies integration is disabled.
615- const shellIntegrationEnabled = vscode . workspace . getConfiguration ( "terminal.integrated.shellIntegration" ) . get < boolean > ( "enabled" ) ;
616- const shellIntegrationScript = path . join ( vscode . env . appRoot , "out" , "vs" , "workbench" , "contrib" , "terminal" , "browser" , "media" , "shellIntegration.ps1" ) ;
617622
618623 const clientOptions : LanguageClientOptions = {
619624 documentSelector : this . documentSelector ,
@@ -624,10 +629,13 @@ export class SessionManager implements Middleware {
624629 // TODO: fileEvents: vscode.workspace.createFileSystemWatcher('**/.eslintrc')
625630 } ,
626631 // NOTE: Some settings are only applicable on startup, so we send them during initialization.
632+ // When Terminal Shell Integration is enabled, we pass the path to the script that the server should execute.
633+ // Passing an empty string implies integration is disabled.
627634 initializationOptions : {
628635 enableProfileLoading : this . sessionSettings . enableProfileLoading ,
629636 initialWorkingDirectory : await validateCwdSetting ( this . logger ) ,
630- shellIntegrationScript : shellIntegrationEnabled ? shellIntegrationScript : "" ,
637+ shellIntegrationScript : this . shellIntegrationEnabled
638+ ? utils . ShellIntegrationScript : "" ,
631639 } ,
632640 errorHandler : {
633641 // Override the default error handler to prevent it from
0 commit comments