Don't filter cargo tasks by scope

Fixes #9093
This commit is contained in:
Oliver Cooper 2021-08-31 20:35:22 +12:00
parent 20f3792d10
commit 0517247bbc

View file

@ -58,21 +58,15 @@ class CargoTaskProvider implements vscode.TaskProvider {
if (definition.type === TASK_TYPE && definition.command) { if (definition.type === TASK_TYPE && definition.command) {
const args = [definition.command].concat(definition.args ?? []); 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; return undefined;
} }
} }
function isWorkspaceFolder(scope?: any): scope is vscode.WorkspaceFolder {
return (scope as vscode.WorkspaceFolder).name !== undefined;
}
export async function buildCargoTask( export async function buildCargoTask(
target: vscode.WorkspaceFolder, scope: vscode.WorkspaceFolder | vscode.TaskScope | undefined,
definition: CargoTaskDefinition, definition: CargoTaskDefinition,
name: string, name: string,
args: string[], args: string[],
@ -115,14 +109,26 @@ export async function buildCargoTask(
exec = new vscode.ProcessExecution(fullCommand[0], fullCommand.slice(1), definition); exec = new vscode.ProcessExecution(fullCommand[0], fullCommand.slice(1), definition);
} }
return new vscode.Task( if (scope) {
definition, return new vscode.Task(
target, definition,
name, scope,
TASK_SOURCE, name,
exec, TASK_SOURCE,
['$rustc'] 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 { export function activateTaskProvider(config: Config): vscode.Disposable {