Skip to content

Commit bae00d6

Browse files
committed
fix #192043
1 parent 54f90d6 commit bae00d6

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

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

+18-5
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,24 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
316316
this._registerCommands().then(() => TaskCommandsRegistered.bindTo(this._contextKeyService).set(true));
317317
ServerlessWebContext.bindTo(this._contextKeyService).set(Platform.isWeb && !remoteAgentService.getConnection()?.remoteAuthority);
318318
this._configurationResolverService.contributeVariable('defaultBuildTask', async (): Promise<string | undefined> => {
319-
let tasks = await this._getTasksForGroup(TaskGroup.Build);
319+
// delay provider activation, we might find a default task in the tasks.json file
320+
let tasks = await this._getTasksForGroup(TaskGroup.Build, true);
320321
if (tasks.length > 0) {
321322
const defaults = this._getDefaultTasks(tasks);
322323
if (defaults.length === 1) {
323324
return defaults[0]._label;
324325
} else if (defaults.length) {
325326
tasks = defaults;
326327
}
328+
} else {
329+
// activate all providers, we haven't found the default build task in the tasks.json file
330+
tasks = await this._getTasksForGroup(TaskGroup.Build);
331+
const defaults = this._getDefaultTasks(tasks);
332+
if (defaults.length === 1) {
333+
return defaults[0]._label;
334+
} else if (defaults.length) {
335+
tasks = defaults;
336+
}
327337
}
328338

329339
let entry: ITaskQuickPickEntry | null | undefined;
@@ -608,6 +618,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
608618
// We need to first wait for extensions to be registered because we might read
609619
// the `TaskDefinitionRegistry` in case `type` is `undefined`
610620
await this._extensionService.whenInstalledExtensionsRegistered();
621+
this._log('Activating task providers ' + type ?? 'all');
611622
await raceTimeout(
612623
Promise.all(this._getActivationEvents(type).map(activationEvent => this._extensionService.activateByEvent(activationEvent))),
613624
5000,
@@ -1418,8 +1429,8 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
14181429
return task;
14191430
}
14201431

1421-
private async _getTasksForGroup(group: TaskGroup): Promise<Task[]> {
1422-
const groups = await this._getGroupedTasks();
1432+
private async _getTasksForGroup(group: TaskGroup, waitToActivate?: boolean): Promise<Task[]> {
1433+
const groups = await this._getGroupedTasks(undefined, waitToActivate);
14231434
const result: Task[] = [];
14241435
groups.forEach(tasks => {
14251436
for (const task of tasks) {
@@ -2001,11 +2012,13 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
20012012
return !definition || !definition.when || this._contextKeyService.contextMatchesRules(definition.when);
20022013
}
20032014

2004-
private async _getGroupedTasks(filter?: ITaskFilter): Promise<TaskMap> {
2015+
private async _getGroupedTasks(filter?: ITaskFilter, waitToActivate?: boolean): Promise<TaskMap> {
20052016
await this._waitForAllSupportedExecutions;
20062017
const type = filter?.type;
20072018
const needsRecentTasksMigration = this._needsRecentTasksMigration();
2008-
await this._activateTaskProviders(filter?.type);
2019+
if (!waitToActivate) {
2020+
await this._activateTaskProviders(filter?.type);
2021+
}
20092022
const validTypes: IStringDictionary<boolean> = Object.create(null);
20102023
TaskDefinitionRegistry.all().forEach(definition => validTypes[definition.taskType] = true);
20112024
validTypes['shell'] = true;

0 commit comments

Comments
 (0)