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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix leaks in terminalTabsList #209370

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/vs/workbench/contrib/terminal/browser/terminalTabsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,16 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {

// Dispose of instance listeners on shutdown to avoid extra work and so tabs don't disappear
// briefly
lifecycleService.onWillShutdown(e => {
this.disposables.add(lifecycleService.onWillShutdown(e => {
dispose(instanceDisposables);
});
instanceDisposables.length = 0;
}));
this.disposables.add(toDisposable(() => {
dispose(instanceDisposables);
instanceDisposables.length = 0;
}));

this.onMouseDblClick(async e => {
this.disposables.add(this.onMouseDblClick(async e => {
const focus = this.getFocus();
if (focus.length === 0) {
const instance = await this._terminalService.createTerminal({ location: TerminalLocation.Panel });
Expand All @@ -149,11 +154,11 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
if (this._getFocusMode() === 'doubleClick' && this.getFocus().length === 1) {
e.element?.focus(true);
}
});
}));

// on left click, if focus mode = single click, focus the element
// unless multi-selection is in progress
this.onMouseClick(async e => {
this.disposables.add(this.onMouseClick(async e => {
if (this._terminalService.getEditingTerminal()?.instanceId === e.element?.instanceId) {
return;
}
Expand All @@ -165,11 +170,11 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
e.element?.focus(true);
}
}
});
}));

// on right click, set the focus to that element
// unless multi-selection is in progress
this.onContextMenu(e => {
this.disposables.add(this.onContextMenu(e => {
if (!e.element) {
this.setSelection([]);
return;
Expand All @@ -178,15 +183,15 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
if (!selection || !selection.find(s => e.element === s)) {
this.setFocus(e.index !== undefined ? [e.index] : []);
}
});
}));

this._terminalTabsSingleSelectedContextKey = TerminalContextKeys.tabsSingularSelection.bindTo(contextKeyService);
this._isSplitContextKey = TerminalContextKeys.splitTerminal.bindTo(contextKeyService);

this.onDidChangeSelection(e => this._updateContextKey());
this.onDidChangeFocus(() => this._updateContextKey());
this.disposables.add(this.onDidChangeSelection(e => this._updateContextKey()));
this.disposables.add(this.onDidChangeFocus(() => this._updateContextKey()));

this.onDidOpen(async e => {
this.disposables.add(this.onDidOpen(async e => {
const instance = e.element;
if (!instance) {
return;
Expand All @@ -195,7 +200,7 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
if (!e.editorOptions.preserveFocus) {
await instance.focusWhenReady();
}
});
}));
if (!this._decorationsProvider) {
this._decorationsProvider = this.disposables.add(instantiationService.createInstance(TabDecorationsProvider));
this.disposables.add(decorationsService.registerDecorationsProvider(this._decorationsProvider));
Expand Down
Loading