@@ -7,7 +7,7 @@ import { identifyShellFromShellPath } from '../../common/terminal/shellDetectors
7
7
import { TerminalShellType } from '../../common/terminal/types' ;
8
8
import { createDeferred , sleep } from '../../common/utils/async' ;
9
9
import { cache } from '../../common/utils/decorators' ;
10
- import { traceVerbose } from '../../logging' ;
10
+ import { traceError , traceVerbose } from '../../logging' ;
11
11
import { IShellIntegrationService } from '../types' ;
12
12
13
13
/**
@@ -30,8 +30,15 @@ export class ShellIntegrationService implements IShellIntegrationService {
30
30
@inject ( IWorkspaceService ) private readonly workspaceService : IWorkspaceService ,
31
31
) { }
32
32
33
- @cache ( - 1 , true )
34
33
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 > {
35
42
const isEnabled = this . workspaceService
36
43
. getConfiguration ( 'terminal' )
37
44
. get < boolean > ( 'integrated.shellIntegration.enabled' ) ! ;
@@ -50,19 +57,25 @@ export class ShellIntegrationService implements IShellIntegrationService {
50
57
// Proposed API is not available, assume shell integration is working at this point.
51
58
return true ;
52
59
}
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
+ }
67
80
}
68
81
}
0 commit comments