diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 6f2d48d1d56..aec5c70c076 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 3c113e46eb2..c72a7b27888 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 4f0d2884b03..331f85cd3cb 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 7b7e528f6fa..dc53ebe2eeb 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];