Skip to content

Commit

Permalink
add condition in executeCommand in case onDidEndTerminalShellExecutio…
Browse files Browse the repository at this point in the history
…n never returns
  • Loading branch information
anthonykim1 committed Oct 29, 2024
1 parent 8b5eeb0 commit 7c0b405
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/client/common/terminal/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,28 @@ export class TerminalService implements ITerminalService, Disposable {

if (terminal.shellIntegration) {
const execution = terminal.shellIntegration.executeCommand(commandLine);
return await new Promise((resolve) => {
const listener = this.terminalManager.onDidEndTerminalShellExecution((e) => {
if (e.execution === execution) {
this.executeCommandListeners.delete(listener);
resolve({ execution, exitCode: e.exitCode });
return await Promise.race([
new Promise<ITerminalExecutedCommand>((resolve) => {
const listener = this.terminalManager.onDidEndTerminalShellExecution((e) => {
if (e.execution === execution) {
this.executeCommandListeners.delete(listener);
resolve({ execution, exitCode: e.exitCode });
}
});
if (listener) {
this.executeCommandListeners.add(listener);
}
});
if (listener) {
this.executeCommandListeners.add(listener);
}
traceVerbose(`Shell Integration is enabled, executeCommand: ${commandLine}`);
});
traceVerbose(`Shell Integration is enabled, executeCommand: ${commandLine}`);
}),
new Promise<undefined>((resolve) => {
setTimeout(() => {
traceVerbose(`Execution timed out, falling back to sendText: ${commandLine}`);
terminal.sendText(commandLine);
resolve(undefined);
return undefined;
}, 10000);
}),
]);
} else {
terminal.sendText(commandLine);
traceVerbose(`Shell Integration is disabled, sendText: ${commandLine}`);
Expand Down

0 comments on commit 7c0b405

Please sign in to comment.