GeezerVison is showing github.com — id(web): Go to Line accepts 0/negatives as line 1, truncates fractions, and silently closes on out-of-range lines · Issue #712 · developing-today/code
id(web): Go to Line accepts 0/negatives as line 1, truncates fractions, and silently closes on out-of-range lines #712Labels app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label) DescriptionProblem
The Go to Line dialog in the pkgs/id web editor (pkgs/id/web/src/goto-line.ts) does not validate the entered line number on Enter. The <input type="number" min="1"> attributes are never enforced, because the keydown handler reads the raw value and acts on it directly — there is no <form> / constraint-validation step.
Verified on main d495a5cd with a temporary vitest probe driving the real dialog (probe since removed; the three cases below reproduce with the existing goto-line.test.ts harness):
- Line
0 (and negatives) are treated as line 1 — and create an invalid selection. goto-line.ts:88 does parseInt(dialogInput?.value ?? "", 10); the only check is Number.isNaN. getLineStartPos (goto-line.ts:36) returns 0 for any targetLine <= 1, so 0 and -3 both dispatch TextSelection.create(doc, 0). ProseMirror logs TextSelection endpoint not pointing into a node with inline content (doc) and the selection lands at doc position 0, outside the code_block. Typing 0 should be rejected, not silently reinterpreted as the top of the file.
- Fractional input is silently truncated.
2.9 moves the cursor to line 2 (doc position 8 in a first\nsecond\nthird doc) because parseInt drops the fraction. A line number is an integer; 2.9 is invalid input, not line 2.
- Out-of-range input closes the dialog with no feedback.
999 in a 3-line document: getLineStartPos returns null, nothing moves, and closeGotoLine() runs unconditionally (goto-line.ts:100) — the dialog disappears and the user cannot tell whether the jump happened, failed, or the line does not exist. The dialog already knows the line count (it renders Line # (1–N) and sets input.max), but the handler never compares against it.
Existing tests (pkgs/id/web/src/goto-line.test.ts) cover only valid inputs (1, 2), Escape, and dialog lifecycle — none of these invalid cases.
Why it matters
Go to Line is a primary navigation affordance in the editor. Silently treating 0/negatives as line 1, truncating fractions, and swallowing out-of-range jumps with no feedback makes navigation unpredictable, and the 0 case additionally constructs a selection ProseMirror itself warns is not inside inline content.
Acceptance criteria
- Entering
0, a negative number, a fractional number (e.g. 2.9), a non-numeric value, or a line greater than the document's line count does not move the cursor and does not silently close-and-forget: the dialog stays open (or reopens/focuses the input) with the invalid value visible/selectable so the user can correct it. A brief inline hint is welcome but not required.
- Valid integers in
[1, lineCount] keep working exactly as today (line 1 → start of the code block content, line N → start of line N).
- New tests in
goto-line.test.ts cover at least: 0, a negative, a fraction, and a value greater than the line count — each asserting the selection did not move and the dialog did not silently succeed.
- The valid-path tests already in
goto-line.test.ts continue to pass.
Suggested fix
In the Enter handler, parse strictly (reject anything that is not a base-10 integer string, e.g. via a Number + Number.isInteger check on the trimmed value rather than bare parseInt), compare against getLineCount(activeView), and only dispatch + closeGotoLine() on success; on failure, keep the dialog open and select the input text.
Single-repo: getLineStartPos / the goto-line dialog exist only in developing-today/code (pkgs/id/web); no copy exists in opencode, openchamber, or dezren39/nix. Activitydeveloping-today-fleet commented on Nov 24, 2026
AUDIT-7 Lane 2 slice 3 — closing evidence. Verified against the issue body and merged implementation PR(s):
The issue had zero comments in the fresh pre-action read; this comment records the missing close evidence. added kind/bugSomething isn't working (prefixed form of the classic bug label) app/idPackage/app: id (pkgs/ or apps/ in this repo) on Nov 25, 2026
MetadataMetadataapp/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label) DevelopmentNo branches or pull requestsIssue actions
|