Title: 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 · GitHub
Open Graph Title: 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
X Title: 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
Description: Problem 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 attributes are never enforced, because the keydown handler reads...
Open Graph Description: Problem 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 attributes are never enf...
X Description: Problem 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">...
Opengraph URL: https://github.com/developing-today/code/issues/712
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web): Go to Line accepts 0/negatives as line 1, truncates fractions, and silently closes on out-of-range lines","articleBody":"## Problem\n\nThe 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 `\u003cinput type=\"number\" min=\"1\">` attributes are never enforced, because the `keydown` handler reads the raw value and acts on it directly — there is no `\u003cform>` / constraint-validation step.\n\nVerified 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):\n\n1. **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 \u003c= 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.\n2. **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.\n3. **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.\n\nExisting tests (`pkgs/id/web/src/goto-line.test.ts`) cover only valid inputs (`1`, `2`), Escape, and dialog lifecycle — none of these invalid cases.\n\n## Why it matters\n\nGo 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.\n\n## Acceptance criteria\n\n- 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.\n- Valid integers in `[1, lineCount]` keep working exactly as today (line 1 → start of the code block content, line N → start of line N).\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.\n- The valid-path tests already in `goto-line.test.ts` continue to pass.\n\n## Suggested fix\n\nIn 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.\n\nSingle-repo: `getLineStartPos` / the goto-line dialog exist only in `developing-today/code` (`pkgs/id/web`); no copy exists in opencode, openchamber, or dezren39/nix.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-24T03:38:03Z","url":"https://github.com/developing-today/code/issues/712"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2d61cee1-3e27-db7b-c714-895282f9b3ec |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB4A:2E4E6F:767888:9E40CF:6B062F2A |
| html-safe-nonce | 693213215e1edecd230882ee8c4c390094a6e6ea9033f2de8cfd9eb0261dc8fa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjRBOjJFNEU2Rjo3Njc4ODg6OUU0MENGOjZCMDYyRjJBIiwidmlzaXRvcl9pZCI6IjM0NDA4MTg3MDM0MzkzNzYxNzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c75e281b074c3490428847897b954aa1c70bff2190b36a08121bf72543ca9e29 |
| hovercard-subject-tag | issue:6008965311 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/712/issue_layout |
| twitter:image | https://opengraph.githubassets.com/272df2bae45e733c4f0dbc6048bef4e265648f955fa44ab46705852bda812080/developing-today/code/issues/712 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/272df2bae45e733c4f0dbc6048bef4e265648f955fa44ab46705852bda812080/developing-today/code/issues/712 |
| og:image:alt | Problem 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 attributes are never enf... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7f961de5dd5c5d4aca24d33f8b3ffb3fb8b2ef53d0a4f32f01f0a790e512f6d3 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 494ea0bb1e0feef734a83e2628697647755e8864 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width