This commit is contained in:
meganrogge
2023-07-10 12:31:39 -07:00
parent 84fc1ff4b3
commit e5782fe70a
@@ -2936,22 +2936,33 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
});
});
};
let globTasksDetected = false;
// First check for globs before checking for the default tasks of the task group
const absoluteURI = EditorResourceAccessor.getOriginalUri(this._editorService.activeEditor);
if (absoluteURI) {
const workspaceFolder = this._contextService.getWorkspaceFolder(absoluteURI);
// fallback to absolute path of the file if it is not in a workspace or relative path cannot be found
const relativePath = workspaceFolder?.uri ? (resources.relativePath(workspaceFolder.uri, absoluteURI) ?? absoluteURI.path) : absoluteURI.path;
if (workspaceFolder) {
const config = this._getConfiguration(workspaceFolder);
globTasksDetected = ((config?.config?.tasks) || []).filter(task => task.group && typeof task.group !== 'string' && typeof task.group.isDefault === 'string').length > 0;
taskGroupTasks = await this._findWorkspaceTasks((task) => {
const currentTaskGroup = task.configurationProperties.group;
if (currentTaskGroup && typeof currentTaskGroup !== 'string' && typeof currentTaskGroup.isDefault === 'string') {
return (currentTaskGroup._id === taskGroup._id && glob.match(currentTaskGroup.isDefault, relativePath));
if (globTasksDetected) {
// fallback to absolute path of the file if it is not in a workspace or relative path cannot be found
const relativePath = workspaceFolder?.uri ? (resources.relativePath(workspaceFolder.uri, absoluteURI) ?? absoluteURI.path) : absoluteURI.path;
taskGroupTasks = await this._findWorkspaceTasks((task) => {
const currentTaskGroup = task.configurationProperties.group;
if (currentTaskGroup && typeof currentTaskGroup !== 'string' && typeof currentTaskGroup.isDefault === 'string') {
return (currentTaskGroup._id === taskGroup._id && glob.match(currentTaskGroup.isDefault, relativePath));
}
return false;
});
}
}
}
return false;
});
if (!globTasksDetected && taskGroupTasks.length === 0) {
taskGroupTasks = await this._findWorkspaceTasksInGroup(TaskGroup.Build, true);
}
const handleMultipleTasks = (areGlobTasks: boolean) => {
@@ -2991,7 +3002,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
// If there's multiple globs that match we want to show the quick picker for those tasks
// We will need to call splitPerGroupType putting globs in defaults and the remaining tasks in none.
// We don't need to carry on after here
if (taskGroupTasks.length > 1) {
if (globTasksDetected && taskGroupTasks.length > 1) {
return handleMultipleTasks(true);
}