Skip to content

Send the editor's code untrimmed so line numbers line up - #12

Merged
ethanzhoucool merged 2 commits into
mainfrom
claude/web-keep-leading-lines
Nov 3, 2026
Merged

ethanzhoucool merged 2 commits into
mainfrom
claude/web-keep-leading-lines

Conversation

@ethanzhoucool

Copy link
Copy Markdown
Owner

Summary

run() in web/static/app.js posted el.code.value.trim() to /v1/explain/all-levels. But everything that shows the result indexes the untrimmed editor text: the gutter's note dots and hover cards, the walkthrough's source snippets, and the "jump to line" buttons (el.code.value.split("\n")). When the paste starts with blank lines, the server never sees them, so every line number in the response points that many lines above the code it describes.

Example: two blank lines, then # helpers, then def double(x): .... The editor shows def double on line 4:

trimmed (main)       server says double() is on line 2; editor shows it on line 4
as typed (this PR)   server says double() is on line 4; editor shows it on line 4

Changes

  • web/static/app.js: send el.code.value exactly as typed. The "Nothing to explain" check still trims, so a whitespace-only editor is still rejected client-side. The same untrimmed value goes to the SSE enrichment request and into the share link, so those stay consistent with the editor too.

Testing

  • node --check web/static/app.js passes.
  • I posted both the trimmed and the untrimmed text to /v1/explain/all-levels (output above). The untrimmed request's line numbers match the editor.
  • pytest: 147 passed, 3 skipped (no Python changes).
  • Not verified in a browser: there is no headless browser in this environment. The change is limited to the two lines shown in the diff.

Generated by Claude Code

claude and others added 2 commits November 2, 2026 07:15
run() posted `el.code.value.trim()`, but the gutter, walkthrough and
"jump to line" buttons index the untrimmed editor text. Any leading
blank lines were dropped before analysis, so every note landed that
many lines above the code it describes: with two blank lines first,
`def double` on editor line 4 was reported on line 2.

The code is now sent exactly as typed, and the empty check still uses
the trimmed text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UigC7feaY8NkAy9oay3GDW
@ethanzhoucool
ethanzhoucool marked this pull request as ready for review November 3, 2026 17:25
@ethanzhoucool
ethanzhoucool merged commit bac0dc5 into main Nov 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants