feat(web): file references can name a span of lines - #6298
Conversation
`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>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ 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.
ApprovabilityVerdict: Needs human review This PR introduces a new feature allowing file references to specify line spans (e.g., You can customize Macroscope's approvability policy. Learn more. |
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>

Fixes #6295.
Foo.ts:20-40andFoo.ts#L20-L40weren't links at all. The position pattern only took:12and:12:5, and the external-scheme guard read:20-40as a URI scheme and gave up.Both parse now.
splitPathAndPositionchecks 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.
--gotoeditors get the argument rebuilt aspath:line,--lineeditors 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-40chip 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-40or GitHub-style#L20-L40), which previously failed to link at all.Path parsing recognizes spans alongside existing
line/line:columnforms. Chat chips showLstart-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
:start-endspan suffixes alongside existing:lineand:line:columnforms; GitHub-style#Lstart-Lendanchors are also converted.Lstart-endlabels and pass span bounds to the file preview.data-lineelements instead of selecting a single element.revealEndLineon file surfaces; non-forward spans (end ≤ start) are collapsed to single-line reveals.Macroscope summarized 470ea62.