Skip to content

Commit 1104706

Browse files
committed
use a promise
1 parent 4e22457 commit 1104706

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
210210
protected _taskSystemInfos: Map<string, ITaskSystemInfo[]>;
211211

212212
protected _workspaceTasksPromise?: Promise<Map<string, IWorkspaceFolderTaskResult>>;
213+
protected _whenTaskSystemReady?: Promise<void>;
213214

214215
protected _taskSystem?: ITaskSystem;
215216
protected _taskSystemListeners?: IDisposable[] = [];
@@ -267,7 +268,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
267268
@IInstantiationService private readonly _instantiationService: IInstantiationService
268269
) {
269270
super();
270-
271+
this._whenTaskSystemReady = Event.toPromise(this.onDidChangeTaskSystemInfo);
271272
this._workspaceTasksPromise = undefined;
272273
this._taskSystem = undefined;
273274
this._taskSystemListeners = undefined;
@@ -378,15 +379,6 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
378379
});
379380
}
380381

381-
private async _waitForTaskSystem(): Promise<void> {
382-
if (this.hasTaskSystemInfo) {
383-
return;
384-
}
385-
// Wait until we have task system info (the extension host and workspace folders are available).
386-
this._logService.trace('RunBuildTask: Awaiting task system info.');
387-
await Event.toPromise(Event.once(this.onDidChangeTaskSystemInfo));
388-
}
389-
390382
private async _reconnectTasks(): Promise<boolean> {
391383
const tasks = await this.getSavedTasks('persistent');
392384
if (!tasks.length) {
@@ -2208,7 +2200,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
22082200
return new Map();
22092201
}
22102202
await this._waitForSupportedExecutions;
2211-
await this._waitForTaskSystem();
2203+
await this._whenTaskSystemReady;
22122204
if (this._workspaceTasksPromise) {
22132205
return this._workspaceTasksPromise;
22142206
}

0 commit comments

Comments
 (0)