Skip to content

Commit 998481e

Browse files
committed
wait for task system
1 parent 5a82dbd commit 998481e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,20 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
373373
this._tasksReconnected = true;
374374
return;
375375
}
376-
this._getTaskSystem();
377376
this.getWorkspaceTasks().then(async () => {
378377
this._tasksReconnected = await this._reconnectTasks();
379378
});
380379
}
381380

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+
382390
private async _reconnectTasks(): Promise<boolean> {
383391
const tasks = await this.getSavedTasks('persistent');
384392
if (!tasks.length) {
@@ -2199,6 +2207,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
21992207
if (!(await this._trust())) {
22002208
return new Map();
22012209
}
2210+
await this._waitForTaskSystem();
22022211
await this._waitForSupportedExecutions;
22032212
// The build task might be run before folder open. On folder open, we need to update the tasks so that
22042213
// all tasks are parsed. #173384
@@ -2750,6 +2759,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
27502759
}
27512760

27522761
private async _runTaskCommand(filter?: string | ITaskIdentifier): Promise<void> {
2762+
await this._waitForTaskSystem();
27532763
if (!filter) {
27542764
return this._doRunTaskCommand();
27552765
}
@@ -2907,6 +2917,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
29072917
title: strings.fetching
29082918
};
29092919
const promise = (async () => {
2920+
await this._waitForTaskSystem();
29102921
let taskGroupTasks: (Task | ConfiguringTask)[] = [];
29112922

29122923
async function runSingleTask(task: Task | undefined, problemMatcherOptions: IProblemMatcherRunOptions | undefined, that: AbstractTaskService) {

0 commit comments

Comments
 (0)