Skip to content

Commit 80ca971

Browse files
authored
Merge pull request microsoft#209032 from microsoft/merogge/event-listeners
register event listeners
2 parents 140b211 + 644e8d4 commit 80ca971

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/vs/workbench/api/browser/mainThreadTask.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { generateUuid } from 'vs/base/common/uuid';
1010
import * as Types from 'vs/base/common/types';
1111
import * as Platform from 'vs/base/common/platform';
1212
import { IStringDictionary } from 'vs/base/common/collections';
13-
import { IDisposable } from 'vs/base/common/lifecycle';
13+
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
1414

1515
import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
1616

@@ -414,7 +414,7 @@ namespace TaskFilterDTO {
414414
}
415415

416416
@extHostNamedCustomer(MainContext.MainThreadTask)
417-
export class MainThreadTask implements MainThreadTaskShape {
417+
export class MainThreadTask extends Disposable implements MainThreadTaskShape {
418418

419419
private readonly _extHostContext: IExtHostContext | undefined;
420420
private readonly _proxy: ExtHostTaskShape;
@@ -426,9 +426,10 @@ export class MainThreadTask implements MainThreadTaskShape {
426426
@IWorkspaceContextService private readonly _workspaceContextServer: IWorkspaceContextService,
427427
@IConfigurationResolverService private readonly _configurationResolverService: IConfigurationResolverService
428428
) {
429+
super();
429430
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostTask);
430431
this._providers = new Map();
431-
this._taskService.onDidStateChange(async (event: ITaskEvent) => {
432+
this._register(this._taskService.onDidStateChange(async (event: ITaskEvent) => {
432433
if (event.kind === TaskEventKind.Changed) {
433434
return;
434435
}
@@ -453,14 +454,15 @@ export class MainThreadTask implements MainThreadTaskShape {
453454
} else if (event.kind === TaskEventKind.End) {
454455
this._proxy.$OnDidEndTask(TaskExecutionDTO.from(task.getTaskExecution()));
455456
}
456-
});
457+
}));
457458
}
458459

459-
public dispose(): void {
460+
public override dispose(): void {
460461
for (const value of this._providers.values()) {
461462
value.disposable.dispose();
462463
}
463464
this._providers.clear();
465+
super.dispose();
464466
}
465467

466468
$createTaskId(taskDTO: ITaskDTO): Promise<string> {

src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
337337
}
338338
return task._label;
339339
});
340-
this._lifecycleService.onBeforeShutdown(e => {
340+
this._register(this._lifecycleService.onBeforeShutdown(e => {
341341
this._willRestart = e.reason !== ShutdownReason.RELOAD;
342-
});
342+
}));
343343
this._register(this.onDidStateChange(e => {
344344
this._log(nls.localize('taskEvent', 'Task Event kind: {0}', e.kind), true);
345345
if (e.kind === TaskEventKind.Changed) {

src/vs/workbench/contrib/tasks/browser/task.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class TaskStatusBarContributions extends Disposable implements IWorkbench
7070
private _registerListeners(): void {
7171
let promise: Promise<void> | undefined = undefined;
7272
let resolve: (value?: void | Thenable<void>) => void;
73-
this._taskService.onDidStateChange(event => {
73+
this._register(this._taskService.onDidStateChange(event => {
7474
if (event.kind === TaskEventKind.Changed) {
7575
this._updateRunningTasksStatus();
7676
}
@@ -116,7 +116,7 @@ export class TaskStatusBarContributions extends Disposable implements IWorkbench
116116
promise = undefined;
117117
});
118118
}
119-
});
119+
}));
120120
}
121121

122122
private async _updateRunningTasksStatus(): Promise<void> {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class TerminalTabbedView extends Disposable {
107107
this._tabTreeIndex = this._terminalService.configHelper.config.tabs.location === 'left' ? 0 : 1;
108108
this._terminalContainerIndex = this._terminalService.configHelper.config.tabs.location === 'left' ? 1 : 0;
109109

110-
_configurationService.onDidChangeConfiguration(e => {
110+
this._register(_configurationService.onDidChangeConfiguration(e => {
111111
if (e.affectsConfiguration(TerminalSettingId.TabsEnabled) ||
112112
e.affectsConfiguration(TerminalSettingId.TabsHideCondition)) {
113113
this._refreshShowTabs();
@@ -121,20 +121,20 @@ export class TerminalTabbedView extends Disposable {
121121
this._splitView.resizeView(this._tabTreeIndex, this._getLastListWidth());
122122
}
123123
}
124-
});
124+
}));
125125
this._register(this._terminalGroupService.onDidChangeInstances(() => this._refreshShowTabs()));
126126
this._register(this._terminalGroupService.onDidChangeGroups(() => this._refreshShowTabs()));
127127

128128
this._attachEventListeners(parentElement, this._terminalContainer);
129129

130-
this._terminalGroupService.onDidChangePanelOrientation((orientation) => {
130+
this._register(this._terminalGroupService.onDidChangePanelOrientation((orientation) => {
131131
this._panelOrientation = orientation;
132132
if (this._panelOrientation === Orientation.VERTICAL) {
133133
this._terminalContainer.classList.add(CssClass.ViewIsVertical);
134134
} else {
135135
this._terminalContainer.classList.remove(CssClass.ViewIsVertical);
136136
}
137-
});
137+
}));
138138

139139
this._splitView = new SplitView(parentElement, { orientation: Orientation.HORIZONTAL, proportionalLayout: false });
140140
this._setupSplitView(terminalOuterContainer);

0 commit comments

Comments
 (0)