editor/code: Enable noUncheckedIndexedAccess ts option

https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess
This commit is contained in:
Tetsuharu Ohzeki 2023-06-28 04:03:53 +09:00
parent bb35d8fa8e
commit 72a3883a71
14 changed files with 124 additions and 52 deletions

View file

@ -1,10 +1,11 @@
import * as vscode from "vscode";
import { assert } from "./util";
import { unwrapUndefinable } from "./undefinable";
export async function applySnippetWorkspaceEdit(edit: vscode.WorkspaceEdit) {
if (edit.entries().length === 1) {
const [uri, edits] = edit.entries()[0];
const [uri, edits] = unwrapUndefinable(edit.entries()[0]);
const editor = await editorFromUri(uri);
if (editor) await applySnippetTextEdits(editor, edits);
return;
@ -68,7 +69,8 @@ export async function applySnippetTextEdits(editor: vscode.TextEditor, edits: vs
});
if (selections.length > 0) editor.selections = selections;
if (selections.length === 1) {
editor.revealRange(selections[0], vscode.TextEditorRevealType.InCenterIfOutsideViewport);
const selection = unwrapUndefinable(selections[0]);
editor.revealRange(selection, vscode.TextEditorRevealType.InCenterIfOutsideViewport);
}
}