Clamp line to > 0 (#176970)

Fixes #176924
This commit is contained in:
Matt Bierner 2023-03-13 08:37:19 -07:00 committed by GitHub
parent 711cd94734
commit 7800bd3492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@ export function scrollEditorToLine(
}
function toRevealRange(line: number, editor: vscode.TextEditor): vscode.Range {
line = Math.max(0, line);
const sourceLine = Math.floor(line);
if (sourceLine >= editor.document.lineCount) {
return new vscode.Range(editor.document.lineCount - 1, 0, editor.document.lineCount - 1, 0);