Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Wait for clear command to execute before reusing terminal #240970

Merged
merged 7 commits into from
Feb 19, 2025
16 changes: 12 additions & 4 deletions src/vs/workbench/api/node/extHostDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,22 @@ export class ExtHostDebugService extends ExtHostDebugServiceBase {

if (configProvider.getConfiguration('debug.terminal').get<boolean>('clearBeforeReusing')) {
// clear terminal before reusing it
let clearCommand: string;
if (shell.indexOf('powershell') >= 0 || shell.indexOf('pwsh') >= 0 || shell.indexOf('cmd.exe') >= 0) {
terminal.sendText('cls');
clearCommand = 'cls';
} else if (shell.indexOf('bash') >= 0) {
terminal.sendText('clear');
clearCommand = 'clear';
} else if (platform.isWindows) {
terminal.sendText('cls');
clearCommand = 'cls';
} else {
terminal.sendText('clear');
clearCommand = 'clear';
}

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