Skip to content

Commit

Permalink
Add more try...catch cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Nov 8, 2023
1 parent 985043d commit d216ebd
Showing 1 changed file with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,30 @@ export class ShellIntegrationService implements IShellIntegrationService {
const deferred = createDeferred<void>();
const timestamp = new Date().getTime();
const name = `Python ${timestamp}`;
const onDidExecuteTerminalCommand = this.appShell.onDidExecuteTerminalCommand?.bind(this.appShell);
const { onDidExecuteTerminalCommand } = this.appShell;
if (!onDidExecuteTerminalCommand) {
// Proposed API is not available, assume shell integration is working at this point.
return true;
}
const disposable = onDidExecuteTerminalCommand((e) => {
if (e.terminal.name === name) {
deferred.resolve();
}
});
const terminal = this.terminalManager.createTerminal({
name,
shellPath: shell,
hideFromUser: true,
});
terminal.sendText(`echo ${shell}`);
const success = await Promise.race([sleep(3000).then(() => false), deferred.promise.then(() => true)]);
disposable.dispose();
return success;
try {
const disposable = onDidExecuteTerminalCommand((e) => {
if (e.terminal.name === name) {
deferred.resolve();
}
});
const terminal = this.terminalManager.createTerminal({
name,
shellPath: shell,
hideFromUser: true,
});
terminal.sendText(`echo ${shell}`);
const success = await Promise.race([sleep(3000).then(() => false), deferred.promise.then(() => true)]);
disposable.dispose();
return success;
} catch (ex) {
traceError(`Failed to subscribe to onDidExecuteTerminalCommand`, ex);
// Proposed API is not available, assume shell integration is working at this point.
return true;
}
}
}

0 comments on commit d216ebd

Please sign in to comment.