Await xterm writes before resolving reuseTerminal

Fixes #129994
This commit is contained in:
Daniel Imms 2021-08-10 05:26:08 -07:00
parent 53ed7fbcac
commit ec19e508a6
3 changed files with 5 additions and 5 deletions

View file

@ -1285,7 +1285,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
}
terminalToReuse.terminal.scrollToBottom();
terminalToReuse.terminal.reuseTerminal(launchConfigs);
await terminalToReuse.terminal.reuseTerminal(launchConfigs);
if (task.command.presentation && task.command.presentation.clear) {
terminalToReuse.terminal.clear();

View file

@ -702,7 +702,7 @@ export interface ITerminalInstance {
*
* @param shell The new launch configuration.
*/
reuseTerminal(shell: IShellLaunchConfig): void;
reuseTerminal(shell: IShellLaunchConfig): Promise<void>;
/**
* Relaunches the terminal, killing it and reusing the launch config used initially. Any

View file

@ -1367,7 +1367,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
}
reuseTerminal(shell: IShellLaunchConfig, reset: boolean = false): void {
async reuseTerminal(shell: IShellLaunchConfig, reset: boolean = false): Promise<void> {
// Unsubscribe any key listener we may have.
this._pressAnyKeyToCloseListener?.dispose();
this._pressAnyKeyToCloseListener = undefined;
@ -1375,12 +1375,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
if (this._xterm) {
if (!reset) {
// Ensure new processes' output starts at start of new line
this._xterm.write('\n\x1b[G');
await new Promise<void>(r => this._xterm!.write('\n\x1b[G', r));
}
// Print initialText if specified
if (shell.initialText) {
this._xterm.writeln(shell.initialText);
await new Promise<void>(r => this._xterm!.writeln(shell.initialText!, r));
}
// Clean up waitOnExit state