Skip to content

Commit 69d372b

Browse files
authored
Merge pull request #285657 from murataslan1/fix/terminal-lifecycle
Fix: Replace terminal tabbed view lifecycle hack with Event.once
2 parents e5957a7 + e120edc commit 69d372b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/vs/workbench/contrib/terminal/browser/terminalTabbedView.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,12 @@ export class TerminalTabbedView extends Disposable {
592592
// be focused. So wait for connection to finish, then focus.
593593
const previousActiveElement = this._tabListElement.ownerDocument.activeElement;
594594
if (previousActiveElement) {
595-
// TODO: Improve lifecycle management this event should be disposed after first fire
596-
this._register(this._terminalService.onDidChangeConnectionState(() => {
595+
const listener = this._register(Event.once(this._terminalService.onDidChangeConnectionState)(() => {
597596
// Only focus the terminal if the activeElement has not changed since focus() was called
598-
// TODO: Hack
599597
if (dom.isActiveElement(previousActiveElement)) {
600598
this._focus();
601599
}
600+
this._store.delete(listener);
602601
}));
603602
}
604603
}

0 commit comments

Comments
 (0)