@@ -9,6 +9,21 @@ import { getConfiguration, getWorkspaceFolders } from '../../common/workspace.ap
99export const SHELL_INTEGRATION_TIMEOUT = 500 ; // 0.5 seconds
1010export const SHELL_INTEGRATION_POLL_INTERVAL = 20 ; // 0.02 seconds
1111
12+ /**
13+ * Use `terminal.integrated.shellIntegration.timeout` setting if available.
14+ * Falls back to defaults based on shell integration enabled state and remote environment.
15+ */
16+ export function getShellIntegrationTimeout ( ) : number {
17+ const config = getConfiguration ( 'terminal.integrated' ) ;
18+ const timeoutValue = config . get < number | undefined > ( 'shellIntegration.timeout' ) ;
19+ if ( typeof timeoutValue !== 'number' || timeoutValue < 0 ) {
20+ const shellIntegrationEnabled = config . get < boolean > ( 'shellIntegration.enabled' , true ) ;
21+ const isRemote = env . remoteName !== undefined ;
22+ return shellIntegrationEnabled ? 5000 : isRemote ? 3000 : 2000 ;
23+ }
24+ return Math . max ( timeoutValue , 500 ) ;
25+ }
26+
1227/**
1328 * Three conditions in a Promise.race:
1429 * 1. Timeout based on VS Code's terminal.integrated.shellIntegration.timeout setting
@@ -20,16 +35,7 @@ export async function waitForShellIntegration(terminal: Terminal): Promise<boole
2035 return true ;
2136 }
2237
23- const config = getConfiguration ( 'terminal.integrated' ) ;
24- const shellIntegrationEnabled = config . get < boolean > ( 'shellIntegration.enabled' , true ) ;
25- const timeoutValue = config . get < number | undefined > ( 'shellIntegration.timeout' ) ;
26- const isRemote = env . remoteName !== undefined ;
27- let timeoutMs : number ;
28- if ( typeof timeoutValue !== 'number' || timeoutValue < 0 ) {
29- timeoutMs = shellIntegrationEnabled ? 5000 : isRemote ? 3000 : 2000 ;
30- } else {
31- timeoutMs = Math . max ( timeoutValue , 500 ) ;
32- }
38+ const timeoutMs = getShellIntegrationTimeout ( ) ;
3339
3440 const disposables : Disposable [ ] = [ ] ;
3541
0 commit comments