@@ -16,7 +16,7 @@ import { getConfiguration, onDidChangeConfiguration } from '../../common/workspa
1616import { isActivatableEnvironment } from '../common/activation' ;
1717import { identifyTerminalShell } from '../common/shellDetector' ;
1818import { getPythonApi } from '../pythonApi' ;
19- import { isWsl , shellIntegrationForActiveTerminal } from './shells/common/shellUtils' ;
19+ import { getShellIntegrationEnabledCache , isWsl , shellIntegrationForActiveTerminal } from './shells/common/shellUtils' ;
2020import { ShellEnvsProvider , ShellSetupState , ShellStartupScriptProvider } from './shells/startupProvider' ;
2121import { handleSettingUpShellProfile } from './shellStartupSetupHandlers' ;
2222import {
@@ -137,6 +137,20 @@ export class TerminalManagerImpl implements TerminalManager {
137137 this . shellSetup . clear ( ) ;
138138 }
139139 }
140+ if ( e . affectsConfiguration ( 'terminal.integrated.shellIntegration.enabled' ) ) {
141+ traceInfo ( 'Shell integration setting changed, invalidating cache' ) ;
142+ const updatedShellIntegrationSetting = await getShellIntegrationEnabledCache ( ) ;
143+ if ( ! updatedShellIntegrationSetting ) {
144+ const shells = new Set (
145+ terminals ( )
146+ . map ( ( t ) => identifyTerminalShell ( t ) )
147+ . filter ( ( t ) => t !== 'unknown' ) ,
148+ ) ;
149+ if ( shells . size > 0 ) {
150+ await this . handleSetupCheck ( shells ) ;
151+ }
152+ }
153+ }
140154 } ) ,
141155 onDidChangeWindowState ( ( e ) => {
142156 this . hasFocus = e . focused ;
@@ -152,27 +166,19 @@ export class TerminalManagerImpl implements TerminalManager {
152166 await Promise . all (
153167 providers . map ( async ( p ) => {
154168 const state = await p . isSetup ( ) ;
155- const currentSetup = state === ShellSetupState . Setup ;
156- // Check if we already processed this shell and the state hasn't changed
157- if ( this . shellSetup . has ( p . shellType ) ) {
158- const cachedSetup = this . shellSetup . get ( p . shellType ) ;
159- if ( currentSetup === cachedSetup ) {
160- traceVerbose ( `Shell profile for ${ p . shellType } already checked, state unchanged.` ) ;
161- return ;
162- }
163- traceVerbose (
164- `Shell profile for ${ p . shellType } state changed from ${ cachedSetup } to ${ currentSetup } , re-evaluating.` ,
165- ) ;
166- }
167- traceVerbose ( `Checking shell profile for ${ p . shellType } .` ) ;
169+ const shellIntegrationEnabled = await getShellIntegrationEnabledCache ( ) ;
170+ traceVerbose ( `Checking shell profile for ${ p . shellType } , with state: ${ state } ` ) ;
168171 if ( state === ShellSetupState . NotSetup ) {
169172 traceVerbose (
170- `WSL detected: ${ isWsl ( ) } , Shell integration available: ${ await shellIntegrationForActiveTerminal (
173+ `WSL detected: ${ isWsl ( ) } , Shell integration available from setting, or active terminal: ${ shellIntegrationEnabled } , or ${ await shellIntegrationForActiveTerminal (
171174 p . name ,
172175 ) } `,
173176 ) ;
174177
175- if ( ( await shellIntegrationForActiveTerminal ( p . name ) ) && ! isWsl ( ) ) {
178+ if (
179+ ( shellIntegrationEnabled || ( await shellIntegrationForActiveTerminal ( p . name ) ) ) &&
180+ ! isWsl ( )
181+ ) {
176182 // Shell integration available and NOT in WSL - skip setup
177183 await p . teardownScripts ( ) ;
178184 this . shellSetup . set ( p . shellType , true ) ;
@@ -188,7 +194,10 @@ export class TerminalManagerImpl implements TerminalManager {
188194 ) ;
189195 }
190196 } else if ( state === ShellSetupState . Setup ) {
191- if ( ( await shellIntegrationForActiveTerminal ( p . name ) ) && ! isWsl ( ) ) {
197+ if (
198+ ( shellIntegrationEnabled || ( await shellIntegrationForActiveTerminal ( p . name ) ) ) &&
199+ ! isWsl ( )
200+ ) {
192201 await p . teardownScripts ( ) ;
193202 traceVerbose (
194203 `Shell integration available for ${ p . shellType } , removed profile script in favor of shell integration.` ,
0 commit comments