@@ -21,6 +21,7 @@ import { FolderOperation } from "../WorkspaceContext";
21
21
import contextKeys from "../contextKeys" ;
22
22
import { Dependency , ResolvedDependency , Target } from "../SwiftPackage" ;
23
23
import { SwiftPluginTaskProvider } from "../tasks/SwiftPluginTaskProvider" ;
24
+ import { FolderContext } from "../FolderContext" ;
24
25
25
26
const LOADING_ICON = "loading~spin" ;
26
27
/**
@@ -174,13 +175,14 @@ export class FileNode {
174
175
class TaskNode {
175
176
constructor (
176
177
public type : string ,
178
+ public id : string ,
177
179
public name : string ,
178
180
private active : boolean
179
181
) { }
180
182
181
183
toTreeItem ( ) : vscode . TreeItem {
182
184
const item = new vscode . TreeItem ( this . name , vscode . TreeItemCollapsibleState . None ) ;
183
- item . id = `${ this . type } -${ this . name } ` ;
185
+ item . id = `${ this . type } -${ this . id } ` ;
184
186
item . iconPath = new vscode . ThemeIcon ( this . active ? LOADING_ICON : "play" ) ;
185
187
item . contextValue = "task" ;
186
188
item . accessibilityInformation = { label : this . name } ;
@@ -445,7 +447,12 @@ export class ProjectPanelProvider implements vscode.TreeDataProvider<TreeNode> {
445
447
]
446
448
: [ ] ) ,
447
449
new HeaderNode ( "targets" , "Targets" , "book" , this . wrapInAsync ( this . targets . bind ( this ) ) ) ,
448
- new HeaderNode ( "tasks" , "Tasks" , "debug-continue-small" , this . tasks . bind ( this ) ) ,
450
+ new HeaderNode (
451
+ "tasks" ,
452
+ "Tasks" ,
453
+ "debug-continue-small" ,
454
+ this . tasks . bind ( this , folderContext )
455
+ ) ,
449
456
...( snippets . length > 0
450
457
? [
451
458
new HeaderNode ( "snippets" , "Snippets" , "notebook" , ( ) =>
@@ -508,16 +515,23 @@ export class ProjectPanelProvider implements vscode.TreeDataProvider<TreeNode> {
508
515
) ;
509
516
}
510
517
511
- private async tasks ( ) : Promise < TreeNode [ ] > {
518
+ private async tasks ( folderContext : FolderContext ) : Promise < TreeNode [ ] > {
512
519
const tasks = await vscode . tasks . fetchTasks ( ) ;
520
+
513
521
return (
514
522
tasks
515
523
// Plugin tasks are shown under the Commands header
516
- . filter ( task => task . source !== "swift-plugin" )
517
- . map (
524
+ . filter (
518
525
task =>
526
+ task . definition . type === "swift" &&
527
+ task . definition . cwd === folderContext . folder . fsPath &&
528
+ task . source !== "swift-plugin"
529
+ )
530
+ . map (
531
+ ( task , i ) =>
519
532
new TaskNode (
520
533
"task" ,
534
+ `${ task . definition . cwd } -${ task . name } -${ task . detail ?? "" } -${ i } ` ,
521
535
task . name ,
522
536
this . activeTasks . has ( task . detail ?? task . name )
523
537
)
@@ -531,9 +545,10 @@ export class ProjectPanelProvider implements vscode.TreeDataProvider<TreeNode> {
531
545
const tasks = await provider . provideTasks ( new vscode . CancellationTokenSource ( ) . token ) ;
532
546
return tasks
533
547
. map (
534
- task =>
548
+ ( task , i ) =>
535
549
new TaskNode (
536
550
"command" ,
551
+ `${ task . definition . cwd } -${ task . name } -${ task . detail ?? "" } -${ i } ` ,
537
552
task . name ,
538
553
this . activeTasks . has ( task . detail ?? task . name )
539
554
)
0 commit comments