@@ -7,7 +7,7 @@ import { identifyShellFromShellPath } from '../../common/terminal/shellDetectors
77import { TerminalShellType } from '../../common/terminal/types' ;
88import { createDeferred , sleep } from '../../common/utils/async' ;
99import { cache } from '../../common/utils/decorators' ;
10- import { traceVerbose } from '../../logging' ;
10+ import { traceError , traceVerbose } from '../../logging' ;
1111import { IShellIntegrationService } from '../types' ;
1212
1313/**
@@ -30,8 +30,15 @@ export class ShellIntegrationService implements IShellIntegrationService {
3030 @inject ( IWorkspaceService ) private readonly workspaceService : IWorkspaceService ,
3131 ) { }
3232
33- @cache ( - 1 , true )
3433 public async isWorking ( shell : string ) : Promise < boolean > {
34+ return this . _isWorking ( shell ) . catch ( ( ex ) => {
35+ traceError ( `Failed to determine if shell supports shell integration` , shell , ex ) ;
36+ return false ;
37+ } ) ;
38+ }
39+
40+ @cache ( - 1 , true )
41+ public async _isWorking ( shell : string ) : Promise < boolean > {
3542 const isEnabled = this . workspaceService
3643 . getConfiguration ( 'terminal' )
3744 . get < boolean > ( 'integrated.shellIntegration.enabled' ) ! ;
@@ -50,19 +57,25 @@ export class ShellIntegrationService implements IShellIntegrationService {
5057 // Proposed API is not available, assume shell integration is working at this point.
5158 return true ;
5259 }
53- const disposable = onDidExecuteTerminalCommand ( ( e ) => {
54- if ( e . terminal . name === name ) {
55- deferred . resolve ( ) ;
56- }
57- } ) ;
58- const terminal = this . terminalManager . createTerminal ( {
59- name,
60- shellPath : shell ,
61- hideFromUser : true ,
62- } ) ;
63- terminal . sendText ( `echo ${ shell } ` ) ;
64- const success = await Promise . race ( [ sleep ( 3000 ) . then ( ( ) => false ) , deferred . promise . then ( ( ) => true ) ] ) ;
65- disposable . dispose ( ) ;
66- return success ;
60+ try {
61+ const disposable = onDidExecuteTerminalCommand ( ( e ) => {
62+ if ( e . terminal . name === name ) {
63+ deferred . resolve ( ) ;
64+ }
65+ } ) ;
66+ const terminal = this . terminalManager . createTerminal ( {
67+ name,
68+ shellPath : shell ,
69+ hideFromUser : true ,
70+ } ) ;
71+ terminal . sendText ( `echo ${ shell } ` ) ;
72+ const success = await Promise . race ( [ sleep ( 3000 ) . then ( ( ) => false ) , deferred . promise . then ( ( ) => true ) ] ) ;
73+ disposable . dispose ( ) ;
74+ return success ;
75+ } catch ( ex ) {
76+ traceVerbose ( `Proposed API is not available, failed to subscribe to onDidExecuteTerminalCommand` , ex ) ;
77+ // Proposed API is not available, assume shell integration is working at this point.
78+ return true ;
79+ }
6780 }
6881}
0 commit comments