fix errors

This commit is contained in:
Sahandevs 2021-02-07 22:06:16 +03:30
parent 3a0234d60f
commit 2f82a84d2a
4 changed files with 11 additions and 6 deletions

View File

@ -138,7 +138,7 @@ export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc
command: "rust-analyzer.applyActionGroup",
title: "",
arguments: [items.map((item) => {
return { label: item.title, arguments: item.command.arguments[0] };
return { label: item.title, arguments: item.command!.arguments![0] };
})],
};

View File

@ -87,12 +87,14 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
if (ctx.config.debug.openDebugPane) {
debugOutput.show(true);
}
const isMultiFolderWorkspace = vscode.workspace.workspaceFolders.length > 1;
const firstWorkspace = vscode.workspace.workspaceFolders[0]; // folder exists or RA is not active.
// folder exists or RA is not active.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const workspaceFolders = vscode.workspace.workspaceFolders!;
const isMultiFolderWorkspace = workspaceFolders.length > 1;
const firstWorkspace = workspaceFolders[0];
const workspace = !isMultiFolderWorkspace || !runnable.args.workspaceRoot ?
firstWorkspace :
vscode.workspace.workspaceFolders.find(w => runnable.args.workspaceRoot?.includes(w.uri.fsPath)) || firstWorkspace;
workspaceFolders.find(w => runnable.args.workspaceRoot?.includes(w.uri.fsPath)) || firstWorkspace;
const wsFolder = path.normalize(workspace.uri.fsPath);
const workspaceQualifier = isMultiFolderWorkspace ? `:${workspace.name}` : '';

View File

@ -146,7 +146,8 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise
overrideCargo: runnable.args.overrideCargo,
};
const target = vscode.workspace.workspaceFolders[0]; // safe, see main activate()
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate()
const cargoTask = await tasks.buildCargoTask(target, definition, runnable.label, args, config.cargoRunner, true);
cargoTask.presentationOptions.clear = true;

View File

@ -62,6 +62,8 @@ function parseSnippet(snip: string): [string, [number, number]] | undefined {
const m = snip.match(/\$(0|\{0:([^}]*)\})/);
if (!m) return undefined;
const placeholder = m[2] ?? "";
if (m.index == null)
return undefined;
const range: [number, number] = [m.index, placeholder.length];
const insert = snip.replace(m[0], placeholder);
return [insert, range];