Skip to content

Commit 511849e

Browse files
authored
Merge pull request microsoft#185925 from microsoft/revert-185812-merogge/workspace-tasks
Revert "Revert "Fix accidently starting all onTaskType extensions when running a build command""
2 parents f93437d + 2b2418f commit 511849e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
723723
});
724724
}
725725

726-
public async getTask(folder: IWorkspace | IWorkspaceFolder | string, identifier: string | ITaskIdentifier, compareId: boolean = false): Promise<Task | undefined> {
726+
public async getTask(folder: IWorkspace | IWorkspaceFolder | string, identifier: string | ITaskIdentifier, compareId: boolean = false, type: string | undefined = undefined): Promise<Task | undefined> {
727727
if (!(await this._trust())) {
728728
return;
729729
}
@@ -760,7 +760,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
760760
}
761761

762762
// We didn't find the task, so we need to ask all resolvers about it
763-
const map = await this._getGroupedTasks();
763+
const map = await this._getGroupedTasks({ type });
764764
let values = map.get(folder);
765765
values = values.concat(map.get(USER_TASKS_GROUP_KEY));
766766

@@ -1834,11 +1834,12 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
18341834
await this._updateWorkspaceTasks();
18351835
const taskFolder = task.getWorkspaceFolder();
18361836
const taskIdentifier = task.configurationProperties.identifier;
1837+
const taskType = CustomTask.is(task) ? task.customizes()?.type : (ContributedTask.is(task) ? task.type : undefined);
18371838
// Since we save before running tasks, the task may have changed as part of the save.
18381839
// However, if the TaskRunSource is not User, then we shouldn't try to fetch the task again
18391840
// since this can cause a new'd task to get overwritten with a provided task.
18401841
taskToRun = ((taskFolder && taskIdentifier && (runSource === TaskRunSource.User))
1841-
? await this.getTask(taskFolder, taskIdentifier) : task) ?? task;
1842+
? await this.getTask(taskFolder, taskIdentifier, false, taskType) : task) ?? task;
18421843
}
18431844
await ProblemMatcherRegistry.onReady();
18441845
const executeResult = runSource === TaskRunSource.Reconnect ? this._getTaskSystem().reconnect(taskToRun, resolver) : this._getTaskSystem().run(taskToRun, resolver);

src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ namespace Configuration {
8383

8484
const taskDefinitionsExtPoint = ExtensionsRegistry.registerExtensionPoint<Configuration.ITaskDefinition[]>({
8585
extensionPoint: 'taskDefinitions',
86+
activationEventsGenerator: (contributions: Configuration.ITaskDefinition[], result: { push(item: string): void }) => {
87+
for (const task of contributions) {
88+
if (task.type) {
89+
result.push(`onTaskType:${task.type}`);
90+
}
91+
}
92+
},
8693
jsonSchema: {
8794
description: nls.localize('TaskDefinitionExtPoint', 'Contributes task kinds'),
8895
type: 'array',

0 commit comments

Comments
 (0)