Merge pull request #137201 from microsoft/tyriar/137155

Improve extension pty terminal tests
This commit is contained in:
Daniel Imms
2021-11-15 09:24:00 -08:00
committed by GitHub
2 changed files with 123 additions and 167 deletions

View File

@@ -275,15 +275,11 @@ export class ExtHostPseudoterminal implements ITerminalChildProcess {
}
input(data: string): void {
if (this._pty.handleInput) {
this._pty.handleInput(data);
}
this._pty.handleInput?.(data);
}
resize(cols: number, rows: number): void {
if (this._pty.setDimensions) {
this._pty.setDimensions({ columns: cols, rows });
}
this._pty.setDimensions?.({ columns: cols, rows });
}
async processBinary(data: string): Promise<void> {
@@ -314,28 +310,22 @@ export class ExtHostPseudoterminal implements ITerminalChildProcess {
startSendingEvents(initialDimensions: ITerminalDimensionsDto | undefined): void {
// Attach the listeners
this._pty.onDidWrite(e => this._onProcessData.fire(e));
if (this._pty.onDidClose) {
this._pty.onDidClose((e: number | void = undefined) => {
this._onProcessExit.fire(e === void 0 ? undefined : e);
});
}
if (this._pty.onDidOverrideDimensions) {
this._pty.onDidOverrideDimensions(e => {
if (e) {
this._onDidChangeProperty.fire({ type: ProcessPropertyType.OverrideDimensions, value: { cols: e.columns, rows: e.rows } });
}
});
}
if (this._pty.onDidChangeName) {
this._pty.onDidChangeName(title => {
this._onDidChangeProperty.fire({ type: ProcessPropertyType.Title, value: title });
});
}
this._pty.onDidClose?.((e: number | void = undefined) => {
this._onProcessExit.fire(e === void 0 ? undefined : e);
});
this._pty.onDidOverrideDimensions?.(e => {
if (e) {
this._onDidChangeProperty.fire({ type: ProcessPropertyType.OverrideDimensions, value: { cols: e.columns, rows: e.rows } });
}
});
this._pty.onDidChangeName?.(title => {
this._onDidChangeProperty.fire({ type: ProcessPropertyType.Title, value: title });
});
this._pty.open(initialDimensions ? initialDimensions : undefined);
if (this._pty.setDimensions && initialDimensions) {
this._pty.setDimensions(initialDimensions);
if (initialDimensions) {
this._pty.setDimensions?.(initialDimensions);
}
this._onProcessReady.fire({ pid: -1, cwd: '', capabilities: this._capabilities });
@@ -586,7 +576,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
protected _setupExtHostProcessListeners(id: number, p: ITerminalChildProcess): IDisposable {
const disposables = new DisposableStore();
disposables.add(p.onProcessReady((e: { pid: number, cwd: string }) => this._proxy.$sendProcessReady(id, e.pid, e.cwd)));
disposables.add(p.onProcessReady(e => this._proxy.$sendProcessReady(id, e.pid, e.cwd)));
disposables.add(p.onDidChangeProperty(property => this._proxy.$sendProcessProperty(id, property)));
// Buffer data events to reduce the amount of messages going to the renderer