Skip to content

Commit

Permalink
fix #192043
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Jul 22, 2024
1 parent 54f90d6 commit 0d2db6a
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,22 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
this._registerCommands().then(() => TaskCommandsRegistered.bindTo(this._contextKeyService).set(true));
ServerlessWebContext.bindTo(this._contextKeyService).set(Platform.isWeb && !remoteAgentService.getConnection()?.remoteAuthority);
this._configurationResolverService.contributeVariable('defaultBuildTask', async (): Promise<string | undefined> => {
let tasks = await this._getTasksForGroup(TaskGroup.Build);
let tasks = await this._getTasksForGroup(TaskGroup.Build, true);
if (tasks.length > 0) {
const defaults = this._getDefaultTasks(tasks);
if (defaults.length === 1) {
return defaults[0]._label;
} else if (defaults.length) {
tasks = defaults;
}
} else {
tasks = await this._getTasksForGroup(TaskGroup.Build, true);
const defaults = this._getDefaultTasks(tasks);
if (defaults.length === 1) {
return defaults[0]._label;
} else if (defaults.length) {
tasks = defaults;
}
}

let entry: ITaskQuickPickEntry | null | undefined;
Expand Down Expand Up @@ -608,6 +616,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
// We need to first wait for extensions to be registered because we might read
// the `TaskDefinitionRegistry` in case `type` is `undefined`
await this._extensionService.whenInstalledExtensionsRegistered();
this._log('Activating task providers ' + type ?? 'all');
await raceTimeout(
Promise.all(this._getActivationEvents(type).map(activationEvent => this._extensionService.activateByEvent(activationEvent))),
5000,
Expand Down Expand Up @@ -1418,8 +1427,8 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
return task;
}

private async _getTasksForGroup(group: TaskGroup): Promise<Task[]> {
const groups = await this._getGroupedTasks();
private async _getTasksForGroup(group: TaskGroup, waitToActivate?: boolean): Promise<Task[]> {
const groups = await this._getGroupedTasks(undefined, waitToActivate);
const result: Task[] = [];
groups.forEach(tasks => {
for (const task of tasks) {
Expand Down Expand Up @@ -2001,11 +2010,14 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
return !definition || !definition.when || this._contextKeyService.contextMatchesRules(definition.when);
}

private async _getGroupedTasks(filter?: ITaskFilter): Promise<TaskMap> {
private async _getGroupedTasks(filter?: ITaskFilter, waitToActivate?: boolean): Promise<TaskMap> {
await this._waitForAllSupportedExecutions;
const type = filter?.type;
const needsRecentTasksMigration = this._needsRecentTasksMigration();
await this._activateTaskProviders(filter?.type);
if (!waitToActivate) {
// when the default is identified, it'll be resolved and its provider will be activated at that time
await this._activateTaskProviders(filter?.type);
}
const validTypes: IStringDictionary<boolean> = Object.create(null);
TaskDefinitionRegistry.all().forEach(definition => validTypes[definition.taskType] = true);
validTypes['shell'] = true;
Expand Down

0 comments on commit 0d2db6a

Please sign in to comment.