Skip to content

Commit d216ebd

Browse files
author
Kartik Raj
committed
Add more try...catch cases
1 parent 985043d commit d216ebd

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/client/terminals/envCollectionActivation/shellIntegrationService.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,30 @@ export class ShellIntegrationService implements IShellIntegrationService {
5252
const deferred = createDeferred<void>();
5353
const timestamp = new Date().getTime();
5454
const name = `Python ${timestamp}`;
55-
const onDidExecuteTerminalCommand = this.appShell.onDidExecuteTerminalCommand?.bind(this.appShell);
55+
const { onDidExecuteTerminalCommand } = this.appShell;
5656
if (!onDidExecuteTerminalCommand) {
5757
// Proposed API is not available, assume shell integration is working at this point.
5858
return true;
5959
}
60-
const disposable = onDidExecuteTerminalCommand((e) => {
61-
if (e.terminal.name === name) {
62-
deferred.resolve();
63-
}
64-
});
65-
const terminal = this.terminalManager.createTerminal({
66-
name,
67-
shellPath: shell,
68-
hideFromUser: true,
69-
});
70-
terminal.sendText(`echo ${shell}`);
71-
const success = await Promise.race([sleep(3000).then(() => false), deferred.promise.then(() => true)]);
72-
disposable.dispose();
73-
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+
traceError(`Failed to subscribe to onDidExecuteTerminalCommand`, ex);
77+
// Proposed API is not available, assume shell integration is working at this point.
78+
return true;
79+
}
7480
}
7581
}

0 commit comments

Comments
 (0)