Surface: open file paths with trailing :line[:col] suffixes#12995
Open
jamesarch wants to merge 1 commit into
Open
Surface: open file paths with trailing :line[:col] suffixes#12995jamesarch wants to merge 1 commit into
jamesarch wants to merge 1 commit into
Conversation
Clicking a file path like src/main.zig:42:10 (the standard compiler output format) currently fails silently because the matched text includes the numeric suffix and never resolves on disk. When the text as-is does not resolve, strip a trailing :line[:col] suffix and try again for both relative and absolute paths. Exact matches take precedence so files whose names contain a numeric suffix still open. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a long-standing paper cut discussed extensively in #1972: clicking a
file path that carries a
:line[:col]suffix (the standard output formatof most compilers, e.g.
src/main.zig:42:10from zig/clang, orfile.scala:47:70as reported here)does nothing today. The URL regex matches the full string including the
numeric suffix, so the path fails to resolve on disk and the click fails
silently (or hands a nonexistent path to the system opener).
With this change, when the clicked text doesn't resolve to a real file
as-is, we strip a trailing
:line[:col](validated to be all digits) andtry again, for both relative paths (resolved against the terminal pwd,
as before) and absolute paths. Exact matches take precedence, so files
whose names genuinely contain a numeric suffix still open correctly.
If neither resolves, behavior is unchanged.
The parsing helper returns the line/column components as well; they are
unused by the system opener today but are the natural parse result of
this format and are relevant to the custom-handler ideas discussed in
#9546.
Includes unit tests for the suffix parser. Tested manually on macOS
against compiler output and
grep -rnoutput. The full test suite wasalso run on Linux (
nix develop -c zig build test); no new failuresversus unpatched main in the same environment, and the new unit test
passes on both platforms.
Disclosure: I used Claude Code to assist with this change, and I have
reviewed and tested every line personally.