Merge pull request #285661 from murataslan1/fix/terminal-view-lifecycle

Fix: Replace terminal view lifecycle hack with Event.once
This commit is contained in:
Daniel Imms
2026-01-02 09:31:47 -08:00
committed by GitHub
@@ -337,13 +337,12 @@ export class TerminalViewPane extends ViewPane {
// be focused. So wait for connection to finish, then focus.
const previousActiveElement = this.element.ownerDocument.activeElement;
if (previousActiveElement) {
// TODO: Improve lifecycle management this event should be disposed after first fire
this._register(this._terminalService.onDidChangeConnectionState(() => {
const listener = this._register(Event.once(this._terminalService.onDidChangeConnectionState)(() => {
// Only focus the terminal if the activeElement has not changed since focus() was called
// TODO: Hack
if (previousActiveElement && dom.isActiveElement(previousActiveElement)) {
this._terminalGroupService.showPanel(true);
}
this._store.delete(listener);
}));
}
}