@@ -36,7 +36,14 @@ export function getTaskRepresentation(task: IConfiguredTask | Task): string {
36
36
export async function getTaskForTool ( id : string | undefined , taskDefinition : { taskLabel ?: string ; taskType ?: string } , workspaceFolder : string , configurationService : IConfigurationService , taskService : ITaskService ) : Promise < Task | undefined > {
37
37
let index = 0 ;
38
38
let task : IConfiguredTask | undefined ;
39
- const configTasks : IConfiguredTask [ ] = ( configurationService . getValue ( 'tasks' ) as { tasks : IConfiguredTask [ ] } ) . tasks ?? [ ] ;
39
+ const workspaceFolderToTaskMap = await taskService . getWorkspaceTasks ( ) ;
40
+ let configTasks : IConfiguredTask [ ] = [ ] ;
41
+ for ( const folder of workspaceFolderToTaskMap . keys ( ) ) {
42
+ const tasksConfig = configurationService . getValue ( 'tasks' , { resource : URI . parse ( folder ) } ) as { tasks : IConfiguredTask [ ] } | undefined ;
43
+ if ( tasksConfig ?. tasks ) {
44
+ configTasks = configTasks . concat ( tasksConfig . tasks ) ;
45
+ }
46
+ }
40
47
for ( const configTask of configTasks ) {
41
48
if ( ! configTask . type || 'hide' in configTask && configTask . hide ) {
42
49
// Skip these as they are not included in the agent prompt and we need to align with
@@ -56,7 +63,18 @@ export async function getTaskForTool(id: string | undefined, taskDefinition: { t
56
63
if ( ! task ) {
57
64
return ;
58
65
}
59
- const configuringTasks : IStringDictionary < ConfiguringTask > | undefined = ( await taskService . getWorkspaceTasks ( ) ) ?. get ( URI . file ( workspaceFolder ) . toString ( ) ) ?. configurations ?. byIdentifier ;
66
+
67
+ let tasksForWorkspace ;
68
+ for ( const [ folder , tasks ] of workspaceFolderToTaskMap ) {
69
+ if ( URI . parse ( folder ) . path === workspaceFolder ) {
70
+ tasksForWorkspace = tasks ;
71
+ break ;
72
+ }
73
+ }
74
+ if ( ! tasksForWorkspace ) {
75
+ return ;
76
+ }
77
+ const configuringTasks : IStringDictionary < ConfiguringTask > | undefined = tasksForWorkspace . configurations ?. byIdentifier ;
60
78
const configuredTask : ConfiguringTask | undefined = Object . values ( configuringTasks ?? { } ) . find ( t => {
61
79
return t . type === task . type && ( t . _label === task . label || t . _label === `${ task . type } : ${ getTaskRepresentation ( task ) } ` || t . _label === getTaskRepresentation ( task ) ) ;
62
80
} ) ;
@@ -65,9 +83,8 @@ export async function getTaskForTool(id: string | undefined, taskDefinition: { t
65
83
resolvedTask = await taskService . tryResolveTask ( configuredTask ) ;
66
84
}
67
85
if ( ! resolvedTask ) {
68
- const customTasks : Task [ ] | undefined = ( await taskService . getWorkspaceTasks ( ) ) ?. get ( URI . file ( workspaceFolder ) . toString ( ) ) ? .set ?. tasks ;
86
+ const customTasks : Task [ ] | undefined = tasksForWorkspace . set ?. tasks ;
69
87
resolvedTask = customTasks ?. find ( t => task . label === t . _label || task . label === t . _label ) ;
70
-
71
88
}
72
89
return resolvedTask ;
73
90
}
0 commit comments