From 72a3883a7128b4eae6f38d6479f33aaaaae4790b Mon Sep 17 00:00:00 2001 From: Tetsuharu Ohzeki Date: Wed, 28 Jun 2023 04:03:53 +0900 Subject: editor/code: Enable `noUncheckedIndexedAccess` ts option https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess --- editors/code/src/debug.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'editors/code/src/debug.ts') diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 8fbd427039e..ede90d707dd 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -6,6 +6,7 @@ import * as ra from "./lsp_ext"; import { Cargo, getRustcId, getSysroot } from "./toolchain"; import { Ctx } from "./ctx"; import { prepareEnv } from "./run"; +import { unwrapUndefinable } from "./undefinable"; const debugOutput = vscode.window.createOutputChannel("Debug"); type DebugConfigProvider = ( @@ -105,12 +106,13 @@ async function getDebugConfiguration( const workspaceFolders = vscode.workspace.workspaceFolders!; const isMultiFolderWorkspace = workspaceFolders.length > 1; const firstWorkspace = workspaceFolders[0]; - const workspace = + const maybeWorkspace = !isMultiFolderWorkspace || !runnable.args.workspaceRoot ? firstWorkspace : workspaceFolders.find((w) => runnable.args.workspaceRoot?.includes(w.uri.fsPath)) || firstWorkspace; + const workspace = unwrapUndefinable(maybeWorkspace); const wsFolder = path.normalize(workspace.uri.fsPath); const workspaceQualifier = isMultiFolderWorkspace ? `:${workspace.name}` : ""; function simplifyPath(p: string): string { @@ -130,12 +132,8 @@ async function getDebugConfiguration( sourceFileMap[`/rustc/${commitHash}/`] = rustlib; } - const debugConfig = knownEngines[debugEngine.id]( - runnable, - simplifyPath(executable), - env, - sourceFileMap - ); + const provider = unwrapUndefinable(knownEngines[debugEngine.id]); + const debugConfig = provider(runnable, simplifyPath(executable), env, sourceFileMap); if (debugConfig.type in debugOptions.engineSettings) { const settingsMap = (debugOptions.engineSettings as any)[debugConfig.type]; for (var key in settingsMap) { -- cgit 1.4.1-3-g733a5