@@ -58,21 +58,15 @@ class CargoTaskProvider implements vscode.TaskProvider {
5858
5959 if ( definition . type === TASK_TYPE && definition . command ) {
6060 const args = [ definition . command ] . concat ( definition . args ?? [ ] ) ;
61- if ( isWorkspaceFolder ( task . scope ) ) {
62- return await buildCargoTask ( task . scope , definition , task . name , args , this . config . cargoRunner ) ;
63- }
61+ return await buildCargoTask ( task . scope , definition , task . name , args , this . config . cargoRunner ) ;
6462 }
6563
6664 return undefined ;
6765 }
6866}
6967
70- function isWorkspaceFolder ( scope ?: any ) : scope is vscode . WorkspaceFolder {
71- return ( scope as vscode . WorkspaceFolder ) . name !== undefined ;
72- }
73-
7468export async function buildCargoTask (
75- target : vscode . WorkspaceFolder ,
69+ scope : vscode . WorkspaceFolder | vscode . TaskScope | undefined ,
7670 definition : CargoTaskDefinition ,
7771 name : string ,
7872 args : string [ ] ,
@@ -115,14 +109,26 @@ export async function buildCargoTask(
115109 exec = new vscode . ProcessExecution ( fullCommand [ 0 ] , fullCommand . slice ( 1 ) , definition ) ;
116110 }
117111
118- return new vscode . Task (
119- definition ,
120- target ,
121- name ,
122- TASK_SOURCE ,
123- exec ,
124- [ '$rustc' ]
125- ) ;
112+ if ( scope ) {
113+ return new vscode . Task (
114+ definition ,
115+ scope ,
116+ name ,
117+ TASK_SOURCE ,
118+ exec ,
119+ [ '$rustc' ]
120+ ) ;
121+ }
122+ else {
123+ // if the original task did not provide a scope retain the original lack of scope
124+ return new vscode . Task (
125+ definition ,
126+ name ,
127+ TASK_SOURCE ,
128+ exec ,
129+ [ '$rustc' ]
130+ ) ;
131+ }
126132}
127133
128134export function activateTaskProvider ( config : Config ) : vscode . Disposable {
0 commit comments