Unnamed repository; edit this file 'description' to name the repository.
Don't filter cargo tasks by scope
Fixes #9093
Oliver Cooper 2021-08-31
parent 20f3792 · commit 0517247
-rw-r--r--editors/code/src/tasks.ts38
1 files changed, 22 insertions, 16 deletions
diff --git a/editors/code/src/tasks.ts b/editors/code/src/tasks.ts
index 1d50d03800..6481822eb4 100644
--- a/editors/code/src/tasks.ts
+++ b/editors/code/src/tasks.ts
@@ -58,21 +58,15 @@ class CargoTaskProvider implements vscode.TaskProvider {
if (definition.type === TASK_TYPE && definition.command) {
const args = [definition.command].concat(definition.args ?? []);
- if (isWorkspaceFolder(task.scope)) {
- return await buildCargoTask(task.scope, definition, task.name, args, this.config.cargoRunner);
- }
+ return await buildCargoTask(task.scope, definition, task.name, args, this.config.cargoRunner);
}
return undefined;
}
}
-function isWorkspaceFolder(scope?: any): scope is vscode.WorkspaceFolder {
- return (scope as vscode.WorkspaceFolder).name !== undefined;
-}
-
export async function buildCargoTask(
- target: vscode.WorkspaceFolder,
+ scope: vscode.WorkspaceFolder | vscode.TaskScope | undefined,
definition: CargoTaskDefinition,
name: string,
args: string[],
@@ -115,14 +109,26 @@ export async function buildCargoTask(
exec = new vscode.ProcessExecution(fullCommand[0], fullCommand.slice(1), definition);
}
- return new vscode.Task(
- definition,
- target,
- name,
- TASK_SOURCE,
- exec,
- ['$rustc']
- );
+ if (scope) {
+ return new vscode.Task(
+ definition,
+ scope,
+ name,
+ TASK_SOURCE,
+ exec,
+ ['$rustc']
+ );
+ }
+ else {
+ // if the original task did not provide a scope retain the original lack of scope
+ return new vscode.Task(
+ definition,
+ name,
+ TASK_SOURCE,
+ exec,
+ ['$rustc']
+ );
+ }
}
export function activateTaskProvider(config: Config): vscode.Disposable {