From 2f82a84d2a06e24296bdbc4e8f50131539d5a749 Mon Sep 17 00:00:00 2001 From: Sahandevs Date: Sun, 7 Feb 2021 22:06:16 +0330 Subject: fix errors --- editors/code/src/client.ts | 2 +- editors/code/src/debug.ts | 10 ++++++---- editors/code/src/run.ts | 3 ++- editors/code/src/snippets.ts | 2 ++ 4 files changed, 11 insertions(+), 6 deletions(-) (limited to 'editors') diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 6f2d48d1d..aec5c70c0 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -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] }; })], }; diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 3c113e46e..c72a7b278 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -87,12 +87,14 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise 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}` : ''; diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts index 4f0d2884b..331f85cd3 100644 --- a/editors/code/src/run.ts +++ b/editors/code/src/run.ts @@ -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; diff --git a/editors/code/src/snippets.ts b/editors/code/src/snippets.ts index 7b7e528f6..dc53ebe2e 100644 --- a/editors/code/src/snippets.ts +++ b/editors/code/src/snippets.ts @@ -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]; -- cgit v1.2.3