Get terminals working

- Instead of a single listener per terminal that handles all events VS
  Code now has a single listener per event that handles that event for
  all terminals.
- Refactor Terminal to extend TerminalProcess to avoid duplicating
  methods. This required some modifications to TerminalProcess to access
  the pid and title and to set the ID.
- Remove our async change to shutdown. This was necessary to avoid
  disposing too early but shutdown already calls dispose so it turns out
  we didn't need to call it ourselves.
- Rename methods to match the command strings.
- Fix getting system shell (uses process.env).
- Use a single bufferer. Since it already supports buffering for
  multiple terminals there's no need to have one per terminal.
- Remove replay/reconnect logic. It's broken and unused so there doesn't
  seem much point in trying to refactor it to fit the changes right now.

While terminals work now there are still a lot of todos.
This commit is contained in:
Asher
2021-04-13 15:34:59 -05:00
parent b1fb9f780b
commit 5ebb096db5
2 changed files with 134 additions and 264 deletions

View File

@@ -45,14 +45,13 @@ const enum ShutdownConstants {
}
export class TerminalProcess extends Disposable implements ITerminalChildProcess {
readonly id = 0;
readonly shouldPersist = false;
private _exitCode: number | undefined;
private _exitMessage: string | undefined;
private _closeTimeout: any;
private _ptyProcess: pty.IPty | undefined;
private _currentTitle: string = '';
protected _ptyProcess: pty.IPty | undefined;
protected _currentTitle: string = '';
private _processStartupComplete: Promise<void> | undefined;
private _isDisposed: boolean = false;
private _windowsShellHelper: WindowsShellHelper | undefined;
@@ -82,6 +81,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
public readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event;
constructor(
public readonly id: number = 0,
private readonly _shellLaunchConfig: IShellLaunchConfig,
cwd: string,
cols: number,
@@ -293,9 +293,9 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
this._onProcessTitleChanged.fire(this._currentTitle);
}
public async shutdown(immediate: boolean): Promise<void> {
public shutdown(immediate: boolean): void {
if (immediate) {
await this._kill();
this._kill();
} else {
if (!this._closeTimeout && !this._isDisposed) {
this._queueProcessExit();