Skip to content

Commit 6928a28

Browse files
authored
Merge pull request microsoft#186025 from microsoft/merogge/task-timing
ensure tasks have been resolved before build task is determined, only show default build tasks in quick-pick
2 parents b1c0c8d + 4f0828a commit 6928a28

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
303303
this._configurationResolverService.contributeVariable('defaultBuildTask', async (): Promise<string | undefined> => {
304304
let tasks = await this._getTasksForGroup(TaskGroup.Build);
305305
if (tasks.length > 0) {
306-
const { none, defaults } = this._splitPerGroupType(tasks);
306+
const defaults = this._getDefaultTasks(tasks);
307307
if (defaults.length === 1) {
308308
return defaults[0]._label;
309-
} else if (defaults.length + none.length > 0) {
310-
tasks = defaults.concat(none);
309+
} else if (defaults.length) {
310+
tasks = defaults;
311311
}
312312
}
313313

@@ -344,7 +344,6 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
344344
}
345345
}));
346346
}
347-
348347
this._upgrade();
349348
}
350349

@@ -2748,7 +2747,16 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
27482747
return true;
27492748
}
27502749

2750+
private async _ensureWorkspaceTasks(): Promise<void> {
2751+
if (!this._workspaceTasksPromise) {
2752+
await this.getWorkspaceTasks();
2753+
} else {
2754+
await this._workspaceTasksPromise;
2755+
}
2756+
}
2757+
27512758
private async _runTaskCommand(filter?: string | ITaskIdentifier): Promise<void> {
2759+
await this._ensureWorkspaceTasks();
27522760
if (!filter) {
27532761
return this._doRunTaskCommand();
27542762
}
@@ -2875,24 +2883,21 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
28752883

28762884
/**
28772885
*
2878-
* @param tasks - The tasks which need filtering from defaults and non-defaults
2879-
* @param taskGlobsInList - This tells splitPerGroupType to filter out globbed tasks (into default), otherwise fall back to boolean
2886+
* @param tasks - The tasks which need to be filtered
2887+
* @param taskGlobsInList - This tells splitPerGroupType to filter out globbed tasks (into defaults)
28802888
* @returns
28812889
*/
2882-
private _splitPerGroupType(tasks: Task[], taskGlobsInList: boolean = false): { none: Task[]; defaults: Task[] } {
2883-
const none: Task[] = [];
2890+
private _getDefaultTasks(tasks: Task[], taskGlobsInList: boolean = false): Task[] {
28842891
const defaults: Task[] = [];
28852892
for (const task of tasks) {
28862893
// At this point (assuming taskGlobsInList is true) there are tasks with matching globs, so only put those in defaults
28872894
if (taskGlobsInList && typeof (task.configurationProperties.group as TaskGroup).isDefault === 'string') {
28882895
defaults.push(task);
28892896
} else if (!taskGlobsInList && (task.configurationProperties.group as TaskGroup).isDefault === true) {
28902897
defaults.push(task);
2891-
} else {
2892-
none.push(task);
28932898
}
28942899
}
2895-
return { none, defaults };
2900+
return defaults;
28962901
}
28972902

28982903
private _runTaskGroupCommand(taskGroup: TaskGroup, strings: {
@@ -2909,7 +2914,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
29092914
title: strings.fetching
29102915
};
29112916
const promise = (async () => {
2912-
2917+
await this._ensureWorkspaceTasks();
29132918
let taskGroupTasks: (Task | ConfiguringTask)[] = [];
29142919

29152920
async function runSingleTask(task: Task | undefined, problemMatcherOptions: IProblemMatcherRunOptions | undefined, that: AbstractTaskService) {
@@ -2961,12 +2966,12 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
29612966
if (tasks.length > 0) {
29622967
// If we're dealing with tasks that were chosen because of a glob match,
29632968
// then put globs in the defaults and everything else in none
2964-
const { none, defaults } = this._splitPerGroupType(tasks, areGlobTasks);
2969+
const defaults = this._getDefaultTasks(tasks, areGlobTasks);
29652970
if (defaults.length === 1) {
29662971
runSingleTask(defaults[0], undefined, this);
29672972
return;
2968-
} else if (defaults.length + none.length > 0) {
2969-
tasks = defaults.concat(none);
2973+
} else if (defaults.length > 0) {
2974+
tasks = defaults;
29702975
}
29712976
}
29722977

0 commit comments

Comments
 (0)