Skip to content

feat(web): file references can name a span of lines - #6298

Open
Brechard wants to merge 3 commits into
pingdotgg:mainfrom
Brechard:feat/file-reference-line-spans
Open

feat(web): file references can name a span of lines#6298
Brechard wants to merge 3 commits into
pingdotgg:mainfrom
Brechard:feat/file-reference-line-spans

Conversation

@Brechard

@Brechard Brechard commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #6295.

Foo.ts:20-40 and Foo.ts#L20-L40 weren't links at all. The position pattern only took :12 and :12:5, and the external-scheme guard read :20-40 as a URI scheme and gave up.

Both parse now. splitPathAndPosition checks for a span before anything else, since the trailing number would otherwise read as a column and leave the - stranded on the path. The end line travels with the file surface into the preview, which marks every row in the range and centres the first one — the same reveal a single-line reference already used, applied to more than one row. It scans the mounted rows rather than querying each number, so a long span costs one pass and virtualized rows pick the mark up as they scroll in. A span that runs backwards, or names one line twice, is treated as its start line.

The same target also reaches the external editor, and no editor takes a span. --goto editors get the argument rebuilt as path:line, --line editors get the end dropped; both open at the range's first line instead of failing on a filename that doesn't exist. Rebuilding leaves every non-span shape byte-identical to what it was, which the launcher test pins.

No screenshots: a Foo.ts:20-40 chip opens the file with rows 20 to 40 highlighted in the existing reveal styling.

🤖 Generated with Claude Code


Note

Medium Risk
Touches shared path parsing used by chat links, file preview reveal, and external editor launch; regressions could break existing single-line or column references, though tests pin non-span behavior.

Overview
File references can now name a line span (Foo.ts:20-40 or GitHub-style #L20-L40), which previously failed to link at all.

Path parsing recognizes spans alongside existing line / line:column forms. Chat chips show Lstart-end, and opening a span reveals the file with every row in the range highlighted while scrolling to the start line. Backwards or degenerate spans collapse to the start line.

External editor launches also accept spans but collapse them to the first line (path:line / --line), since no editor CLI takes a range. Non-span targets stay byte-identical.

Reviewed by Cursor Bugbot for commit 470ea62. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add line span support to file references in chat, preview, and editor launch

  • Updates regex patterns in markdown-links.ts and terminal-links.ts to parse :start-end span suffixes alongside existing :line and :line:column forms; GitHub-style #Lstart-Lend anchors are also converted.
  • Chat file link chips in ChatMarkdown.tsx now display Lstart-end labels and pass span bounds to the file preview.
  • FilePreviewPanel.tsx highlights the full line range by iterating over all matching data-line elements instead of selecting a single element.
  • rightPanelStore.ts stores revealEndLine on file surfaces; non-forward spans (end ≤ start) are collapsed to single-line reveals.
  • externalLauncher.ts collapses spans to their start line when building editor launch arguments, handling goto, direct-path, and line-column editor styles correctly.

Macroscope summarized 470ea62.

`Foo.ts:20-40` and GitHub's `Foo.ts#L20-L40` were not links at all. The
position pattern only accepted `:12` and `:12:5`, and the external-scheme
guard read `:20-40` as a URI scheme and gave up.

Both forms parse now. `splitPathAndPosition` checks the span first, since its
trailing number would otherwise read as a column and leave the `-` stranded on
the path. The end line travels with the file surface into the preview, which
highlights every line in the range and centres the first one. A span that runs
backwards, or names one line twice, is treated as its start line.

The same target reaches the external editor, and no editor takes a span. For
`--goto` editors the argument is rebuilt as `path:line`, for `--line` editors
the end is dropped; both open at the range's first line rather than failing on
a filename that does not exist. Rebuilding also leaves every non-span shape
byte-identical to what it was.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cc24eef2-6cc4-45d7-a533-34f74be1e636

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 12, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c494c8e. Configure here.

Comment thread apps/server/src/process/externalLauncher.ts
@macroscopeapp

macroscopeapp Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces a new feature allowing file references to specify line spans (e.g., file.ts:20-40), with changes across parsing logic, store state management, and UI rendering. New user-facing capabilities warrant human review to validate the intended behavior.

You can customize Macroscope's approvability policy. Learn more.

rodrigoB-CB and others added 2 commits August 12, 2026 11:38
Zed takes the target as-is, so it was still handed `path:20-40` and failed on
a filename that does not exist. Span collapsing was only wired into the
`--goto` and `--line` styles.

All three styles now share one positional target rebuilt from the parse, which
is byte-identical to the incoming string for every shape that is not a span.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three of the notes added here explained more than the code needed, against a
1% comment-line median for the modules they sit in.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File references can't name a range of lines

2 participants