Skip to content

Commit 13991f6

Browse files
committed
clean up and add comment
1 parent e5782fe commit 13991f6

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,7 +2908,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
29082908
title: strings.fetching
29092909
};
29102910
const promise = (async () => {
2911-
let taskGroupTasks: (Task | ConfiguringTask)[] = [];
2911+
let groupTasks: (Task | ConfiguringTask)[] = [];
29122912

29132913
async function runSingleTask(task: Task | undefined, problemMatcherOptions: IProblemMatcherRunOptions | undefined, that: AbstractTaskService) {
29142914
that.run(task, problemMatcherOptions, TaskRunSource.User).then(undefined, reason => {
@@ -2942,27 +2942,29 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
29422942
if (absoluteURI) {
29432943
const workspaceFolder = this._contextService.getWorkspaceFolder(absoluteURI);
29442944
if (workspaceFolder) {
2945-
const config = this._getConfiguration(workspaceFolder);
2946-
globTasksDetected = ((config?.config?.tasks) || []).filter(task => task.group && typeof task.group !== 'string' && typeof task.group.isDefault === 'string').length > 0;
2947-
2948-
if (globTasksDetected) {
2949-
// fallback to absolute path of the file if it is not in a workspace or relative path cannot be found
2950-
const relativePath = workspaceFolder?.uri ? (resources.relativePath(workspaceFolder.uri, absoluteURI) ?? absoluteURI.path) : absoluteURI.path;
2951-
2952-
taskGroupTasks = await this._findWorkspaceTasks((task) => {
2953-
const currentTaskGroup = task.configurationProperties.group;
2954-
if (currentTaskGroup && typeof currentTaskGroup !== 'string' && typeof currentTaskGroup.isDefault === 'string') {
2955-
return (currentTaskGroup._id === taskGroup._id && glob.match(currentTaskGroup.isDefault, relativePath));
2956-
}
2945+
const configuredTasks = this._getConfiguration(workspaceFolder)?.config?.tasks;
2946+
if (configuredTasks) {
2947+
globTasksDetected = configuredTasks.filter(task => task.group && typeof task.group !== 'string' && typeof task.group.isDefault === 'string').length > 0;
2948+
// This will activate extensions, so only do so if necessary #185960
2949+
if (globTasksDetected) {
2950+
// Fallback to absolute path of the file if it is not in a workspace or relative path cannot be found
2951+
const relativePath = workspaceFolder?.uri ? (resources.relativePath(workspaceFolder.uri, absoluteURI) ?? absoluteURI.path) : absoluteURI.path;
2952+
2953+
groupTasks = await this._findWorkspaceTasks((task) => {
2954+
const currentTaskGroup = task.configurationProperties.group;
2955+
if (currentTaskGroup && typeof currentTaskGroup !== 'string' && typeof currentTaskGroup.isDefault === 'string') {
2956+
return (currentTaskGroup._id === taskGroup._id && glob.match(currentTaskGroup.isDefault, relativePath));
2957+
}
29572958

2958-
return false;
2959-
});
2959+
return false;
2960+
});
2961+
}
29602962
}
29612963
}
29622964
}
29632965

2964-
if (!globTasksDetected && taskGroupTasks.length === 0) {
2965-
taskGroupTasks = await this._findWorkspaceTasksInGroup(TaskGroup.Build, true);
2966+
if (!globTasksDetected && groupTasks.length === 0) {
2967+
groupTasks = await this._findWorkspaceTasksInGroup(TaskGroup.Build, true);
29662968
}
29672969

29682970
const handleMultipleTasks = (areGlobTasks: boolean) => {
@@ -2995,25 +2997,25 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
29952997
};
29962998

29972999
// A single default glob task was returned, just run it directly
2998-
if (taskGroupTasks.length === 1) {
2999-
return resolveTaskAndRun(taskGroupTasks[0]);
3000+
if (groupTasks.length === 1) {
3001+
return resolveTaskAndRun(groupTasks[0]);
30003002
}
30013003

30023004
// If there's multiple globs that match we want to show the quick picker for those tasks
30033005
// We will need to call splitPerGroupType putting globs in defaults and the remaining tasks in none.
30043006
// We don't need to carry on after here
3005-
if (globTasksDetected && taskGroupTasks.length > 1) {
3007+
if (globTasksDetected && groupTasks.length > 1) {
30063008
return handleMultipleTasks(true);
30073009
}
30083010

30093011
// If no globs are found or matched fallback to checking for default tasks of the task group
3010-
if (!taskGroupTasks.length) {
3011-
taskGroupTasks = await this._findWorkspaceTasksInGroup(taskGroup, false);
3012+
if (!groupTasks.length) {
3013+
groupTasks = await this._findWorkspaceTasksInGroup(taskGroup, false);
30123014
}
30133015

30143016
// A single default task was returned, just run it directly
3015-
if (taskGroupTasks.length === 1) {
3016-
return resolveTaskAndRun(taskGroupTasks[0]);
3017+
if (groupTasks.length === 1) {
3018+
return resolveTaskAndRun(groupTasks[0]);
30173019
}
30183020

30193021
// Multiple default tasks returned, show the quickPicker

0 commit comments

Comments
 (0)