diff --git a/src/vs/workbench/contrib/terminal/browser/terminalView.ts b/src/vs/workbench/contrib/terminal/browser/terminalView.ts index 628e1313ba5c..01b62d5c1d2c 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalView.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalView.ts @@ -337,10 +337,8 @@ 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(() => { + 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); }