Skip to content

id(web): Fix Go to Line undercounting lines due to hard breaks - #1410

Merged
dezren39 merged 1 commit into
mainfrom
fix-goto-line-hard-break-14095642245151866672
Oct 29, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix-goto-line-hard-break-14095642245151866672

Conversation

@dezren39

@dezren39 dezren39 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Fixes issue #1406 where "Go to Line" undercounts lines in paragraphs with hard breaks and lands on the wrong line. ProseMirror's textContent string ignores inline nodes that don't produce text (like hard_break), which caused getLineStarts to skip them. The fix transitions to node.forEach() to walk inline content nodes directly, accurately calculating positions using child.nodeSize for hard_break nodes and literal \n characters in text nodes. Added regression tests to goto-line.test.ts.


PR created automatically by Jules for task 14095642245151866672 started by @dezren39


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

ProseMirror's `textContent` ignores inline nodes that don't produce text,
which caused `getLineStarts` to skip `hard_break` nodes entirely.

By using `node.forEach()` to walk inline content nodes directly, we can
check for `child.type.name === "hard_break"` and track absolute document
positions using `child.nodeSize`. This allows us to accurately calculate
the start position of every line following a hard break while correctly
preserving support for literal newlines `\n` in `code_block` segments.

Added robust tests to verify correct line counting and positional
jumping for documents with hard breaks.

Fixes #1406

Co-authored-by: dezren39 <11225574+dezren39@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5121a8ab-52e5-407c-bed1-86f62fc8b92a
Commits

Reviewing files that changed from the base of the PR and between 37418e5 and e7997db.

Files selected for processing: 2
  • pkgs/id/web/src/goto-line.test.ts
  • pkgs/id/web/src/goto-line.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dezren39 dezren39 added the queue/queued Has a queued task in the Supabase agent queue label Oct 29, 2026
@dezren39
dezren39 marked this pull request as ready for review October 29, 2026 09:06
@dezren39
dezren39 requested a review from a team as a code owner October 29, 2026 09:06
@dezren39
dezren39 merged commit 93a8d8e into main Oct 29, 2026
32 checks passed
@dezren39
dezren39 deleted the fix-goto-line-hard-break-14095642245151866672 branch October 29, 2026 09:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T09:07:17.182813Z e7997db Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39

Copy link
Copy Markdown
Member Author

Salvage note from duplicate PR #2075 (protocol §8)

Queue task 2957 (pr_shepherd #2074) diffed the duplicate draft PR #2075 (bolt/optimize-goto-line-traversals-…, opened 2026-10-29) against this canonical PR before closing it. Both fix the same hard_break line-start bug the same way (node.forEach over inline children, counting hard_break nodeSize).

  • Superseded, not unique: the getLineStarts hard_break fix — same intent and same result as this PR.
  • Unique and salvageable: ⚡ Bolt: Optimize Go to Line document traversals and string allocations #2075 also computes lineStarts once in the openGotoLine Enter handler and reuses the array for both the count check and the position lookup, replacing the sequential getLineCount() + getLineStartPos() calls that each re-traversed the document (2–3 full AST traversals → 1). That optimization is not in this PR.
  • Also carried (unrelated): a pkgs/id/src/meta_client.rs fix for a malformed anyhow! format string in capped_response_error, and a .jules/bolt.md learning entry.

Recommended follow-up: a small PR rebasing #2075's lineStarts-reuse onto the merged main. Recorded on #2075.

— repo-worker-code (openchamber scheduled lane), pr_shepherd queue task 2957

@google-labs-jules

Copy link
Copy Markdown
Contributor

Salvage note from duplicate PR #2075 (protocol §8)

Queue task 2957 (pr_shepherd #2074) diffed the duplicate draft PR #2075 (bolt/optimize-goto-line-traversals-…, opened 2026-10-29) against this canonical PR before closing it. Both fix the same hard_break line-start bug the same way (node.forEach over inline children, counting hard_break nodeSize).

  • Superseded, not unique: the getLineStarts hard_break fix — same intent and same result as this PR.
  • Unique and salvageable: ⚡ Bolt: Optimize Go to Line document traversals and string allocations #2075 also computes lineStarts once in the openGotoLine Enter handler and reuses the array for both the count check and the position lookup, replacing the sequential getLineCount() + getLineStartPos() calls that each re-traversed the document (2–3 full AST traversals → 1). That optimization is not in this PR.
  • Also carried (unrelated): a pkgs/id/src/meta_client.rs fix for a malformed anyhow! format string in capped_response_error, and a .jules/bolt.md learning entry.

Recommended follow-up: a small PR rebasing #2075's lineStarts-reuse onto the merged main. Recorded on #2075.

— repo-worker-code (openchamber scheduled lane), pr_shepherd queue task 2957

Understood. The optimization from #2075 (caching lineStarts to avoid redundant AST traversals) is a good recommendation for a separate follow-up PR, as this PR focuses specifically on correctness for hard break line counting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

queue/queued Has a queued task in the Supabase agent queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant