Skip to content

Commit e5782fe

Browse files
committed
1 parent 84fc1ff commit e5782fe

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,22 +2936,33 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
29362936
});
29372937
});
29382938
};
2939-
2939+
let globTasksDetected = false;
29402940
// First check for globs before checking for the default tasks of the task group
29412941
const absoluteURI = EditorResourceAccessor.getOriginalUri(this._editorService.activeEditor);
29422942
if (absoluteURI) {
29432943
const workspaceFolder = this._contextService.getWorkspaceFolder(absoluteURI);
2944-
// fallback to absolute path of the file if it is not in a workspace or relative path cannot be found
2945-
const relativePath = workspaceFolder?.uri ? (resources.relativePath(workspaceFolder.uri, absoluteURI) ?? absoluteURI.path) : absoluteURI.path;
2944+
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+
}
29462957

2947-
taskGroupTasks = await this._findWorkspaceTasks((task) => {
2948-
const currentTaskGroup = task.configurationProperties.group;
2949-
if (currentTaskGroup && typeof currentTaskGroup !== 'string' && typeof currentTaskGroup.isDefault === 'string') {
2950-
return (currentTaskGroup._id === taskGroup._id && glob.match(currentTaskGroup.isDefault, relativePath));
2958+
return false;
2959+
});
29512960
}
2961+
}
2962+
}
29522963

2953-
return false;
2954-
});
2964+
if (!globTasksDetected && taskGroupTasks.length === 0) {
2965+
taskGroupTasks = await this._findWorkspaceTasksInGroup(TaskGroup.Build, true);
29552966
}
29562967

29572968
const handleMultipleTasks = (areGlobTasks: boolean) => {
@@ -2991,7 +3002,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
29913002
// If there's multiple globs that match we want to show the quick picker for those tasks
29923003
// We will need to call splitPerGroupType putting globs in defaults and the remaining tasks in none.
29933004
// We don't need to carry on after here
2994-
if (taskGroupTasks.length > 1) {
3005+
if (globTasksDetected && taskGroupTasks.length > 1) {
29953006
return handleMultipleTasks(true);
29963007
}
29973008

0 commit comments

Comments
 (0)