Skip to content

Commit

Permalink
Add event listner to executeCommand to ensure and await execution
Browse files Browse the repository at this point in the history
  • Loading branch information
tcvdh authored Feb 19, 2025
1 parent 14a2454 commit 37ac155
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/vs/workbench/api/node/extHostDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,18 @@ export class ExtHostDebugService extends ExtHostDebugServiceBase {
}

if (terminal.shellIntegration) {
terminal.shellIntegration.executeCommand(clearCommand);
const ds = new DisposableStore();
const execution = terminal.shellIntegration.executeCommand(clearCommand);
await new Promise<void>(resolve => {
ds.add(this._terminalShellIntegrationService.onDidEndTerminalShellExecution(e => {
if (e.execution === execution) {
resolve();
}
}));
ds.add(disposableTimeout(resolve, 5000)); // 5s timeout to ensure we resolve
});

ds.dispose();
} else {
terminal.sendText(clearCommand);
await timeout(200); // add a small delay to ensure the command is processed, see #240953
Expand Down

0 comments on commit 37ac155

Please sign in to comment.