Merge pull request #209032 from microsoft/merogge/event-listeners

register event listeners
This commit is contained in:
Megan Rogge 2024-03-28 10:47:55 -07:00 committed by GitHub
commit 80ca971617
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 13 deletions

View file

@ -10,7 +10,7 @@ import { generateUuid } from 'vs/base/common/uuid';
import * as Types from 'vs/base/common/types';
import * as Platform from 'vs/base/common/platform';
import { IStringDictionary } from 'vs/base/common/collections';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
@ -414,7 +414,7 @@ namespace TaskFilterDTO {
}
@extHostNamedCustomer(MainContext.MainThreadTask)
export class MainThreadTask implements MainThreadTaskShape {
export class MainThreadTask extends Disposable implements MainThreadTaskShape {
private readonly _extHostContext: IExtHostContext | undefined;
private readonly _proxy: ExtHostTaskShape;
@ -426,9 +426,10 @@ export class MainThreadTask implements MainThreadTaskShape {
@IWorkspaceContextService private readonly _workspaceContextServer: IWorkspaceContextService,
@IConfigurationResolverService private readonly _configurationResolverService: IConfigurationResolverService
) {
super();
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostTask);
this._providers = new Map();
this._taskService.onDidStateChange(async (event: ITaskEvent) => {
this._register(this._taskService.onDidStateChange(async (event: ITaskEvent) => {
if (event.kind === TaskEventKind.Changed) {
return;
}
@ -453,14 +454,15 @@ export class MainThreadTask implements MainThreadTaskShape {
} else if (event.kind === TaskEventKind.End) {
this._proxy.$OnDidEndTask(TaskExecutionDTO.from(task.getTaskExecution()));
}
});
}));
}
public dispose(): void {
public override dispose(): void {
for (const value of this._providers.values()) {
value.disposable.dispose();
}
this._providers.clear();
super.dispose();
}
$createTaskId(taskDTO: ITaskDTO): Promise<string> {

View file

@ -337,9 +337,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
return task._label;
});
this._lifecycleService.onBeforeShutdown(e => {
this._register(this._lifecycleService.onBeforeShutdown(e => {
this._willRestart = e.reason !== ShutdownReason.RELOAD;
});
}));
this._register(this.onDidStateChange(e => {
this._log(nls.localize('taskEvent', 'Task Event kind: {0}', e.kind), true);
if (e.kind === TaskEventKind.Changed) {

View file

@ -70,7 +70,7 @@ export class TaskStatusBarContributions extends Disposable implements IWorkbench
private _registerListeners(): void {
let promise: Promise<void> | undefined = undefined;
let resolve: (value?: void | Thenable<void>) => void;
this._taskService.onDidStateChange(event => {
this._register(this._taskService.onDidStateChange(event => {
if (event.kind === TaskEventKind.Changed) {
this._updateRunningTasksStatus();
}
@ -116,7 +116,7 @@ export class TaskStatusBarContributions extends Disposable implements IWorkbench
promise = undefined;
});
}
});
}));
}
private async _updateRunningTasksStatus(): Promise<void> {

View file

@ -107,7 +107,7 @@ export class TerminalTabbedView extends Disposable {
this._tabTreeIndex = this._terminalService.configHelper.config.tabs.location === 'left' ? 0 : 1;
this._terminalContainerIndex = this._terminalService.configHelper.config.tabs.location === 'left' ? 1 : 0;
_configurationService.onDidChangeConfiguration(e => {
this._register(_configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(TerminalSettingId.TabsEnabled) ||
e.affectsConfiguration(TerminalSettingId.TabsHideCondition)) {
this._refreshShowTabs();
@ -121,20 +121,20 @@ export class TerminalTabbedView extends Disposable {
this._splitView.resizeView(this._tabTreeIndex, this._getLastListWidth());
}
}
});
}));
this._register(this._terminalGroupService.onDidChangeInstances(() => this._refreshShowTabs()));
this._register(this._terminalGroupService.onDidChangeGroups(() => this._refreshShowTabs()));
this._attachEventListeners(parentElement, this._terminalContainer);
this._terminalGroupService.onDidChangePanelOrientation((orientation) => {
this._register(this._terminalGroupService.onDidChangePanelOrientation((orientation) => {
this._panelOrientation = orientation;
if (this._panelOrientation === Orientation.VERTICAL) {
this._terminalContainer.classList.add(CssClass.ViewIsVertical);
} else {
this._terminalContainer.classList.remove(CssClass.ViewIsVertical);
}
});
}));
this._splitView = new SplitView(parentElement, { orientation: Orientation.HORIZONTAL, proportionalLayout: false });
this._setupSplitView(terminalOuterContainer);