From 0a315ec2da3c04adf45daae4e5a432a32b3d6cd9 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Fri, 30 Oct 2026 10:14:28 -0500 Subject: [PATCH 1/2] fix(id/web): Go to Line accepts only decimal digits (#2776) --- pkgs/id/web/src/goto-line.test.ts | 7 +++++++ pkgs/id/web/src/goto-line.ts | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkgs/id/web/src/goto-line.test.ts b/pkgs/id/web/src/goto-line.test.ts index aac529aee4..94021d9414 100644 --- a/pkgs/id/web/src/goto-line.test.ts +++ b/pkgs/id/web/src/goto-line.test.ts @@ -304,6 +304,13 @@ describe("dialog input interaction", () => { ["0", "zero"], ["-3", "negative"], ["2.9", "fractional"], + // #2776: non-decimal spellings that Number() reinterprets as the + // in-range line 2 — out-of-range spellings could not distinguish + // acceptance from rejection on this 3-line fixture. + ["0x2", "hex for line 2"], + ["0b10", "binary for line 2"], + ["2.0", "decimal point for line 2"], + ["+2", "signed line 2"], ["999", "out of range"], ["", "empty"], ])( diff --git a/pkgs/id/web/src/goto-line.ts b/pkgs/id/web/src/goto-line.ts index ec26e10749..5c5d9dec0d 100644 --- a/pkgs/id/web/src/goto-line.ts +++ b/pkgs/id/web/src/goto-line.ts @@ -111,7 +111,11 @@ function openGotoLine(view: EditorView): void { // Invalid input keeps the dialog open with the text selected so // the user can correct it; the cursor does not move. const raw = (dialogInput?.value ?? "").trim(); - const line = Number(raw); + // Only a run of decimal digits counts (#2776): Number() alone + // also reinterprets hex/binary/scientific spellings the field + // never showed as that line ("0x10" -> 16, "1e2" -> 100, + // "2.0" -> 2) — the parseWorldSeed rule (#832). + const line = /^\d+$/.test(raw) ? Number(raw) : NaN; // ⚡ Bolt optimization: compute line starts once instead of traversing doc twice const lineStarts = activeView ? getLineStarts(activeView) : []; const lineCount = Math.max(1, lineStarts.length); From bc86d8d80cae41f30c75a9716364be7497ac25d0 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Fri, 30 Oct 2026 10:17:17 -0500 Subject: [PATCH 2/2] style(id/web): use Number.NaN in goto-line validation (#2776) --- pkgs/id/web/src/goto-line.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/id/web/src/goto-line.ts b/pkgs/id/web/src/goto-line.ts index 5c5d9dec0d..e15afa693f 100644 --- a/pkgs/id/web/src/goto-line.ts +++ b/pkgs/id/web/src/goto-line.ts @@ -115,7 +115,7 @@ function openGotoLine(view: EditorView): void { // also reinterprets hex/binary/scientific spellings the field // never showed as that line ("0x10" -> 16, "1e2" -> 100, // "2.0" -> 2) — the parseWorldSeed rule (#832). - const line = /^\d+$/.test(raw) ? Number(raw) : NaN; + const line = /^\d+$/.test(raw) ? Number(raw) : Number.NaN; // ⚡ Bolt optimization: compute line starts once instead of traversing doc twice const lineStarts = activeView ? getLineStarts(activeView) : []; const lineCount = Math.max(1, lineStarts.length);