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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes detaching a terminal editor doesn't fire vscode.window.onDidCloseTerminal event #154546

Merged
merged 4 commits into from
Oct 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}

override dispose(reason?: TerminalExitReason): void {
if (this._isDisposed) {
return;
}
this._isDisposed = true;
this._logService.trace(`terminalInstance#dispose (instanceId: ${this.instanceId})`);
dispose(this._linkManager);
this._linkManager = undefined;
Expand All @@ -1224,7 +1228,13 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._horizontalScrollbar.dispose();
this._horizontalScrollbar = undefined;
}
this.xterm?.dispose();

try {
this.xterm?.dispose();
} catch (err: unknown) {
// See https://github.com/microsoft/vscode/issues/153486
this._logService.error('Exception occurred during xterm disposal', err);
}

// HACK: Workaround for Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=559561,
// as 'blur' event in xterm.raw.textarea is not triggered on xterm.dispose()
Expand All @@ -1249,10 +1259,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// hasn't happened yet
this._onProcessExit(undefined);

if (!this._isDisposed) {
this._isDisposed = true;
this._onDisposed.fire(this);
}
this._onDisposed.fire(this);

super.dispose();
}

Expand Down