Skip to content

Surface: open file paths with trailing :line[:col] suffixes#12995

Open
jamesarch wants to merge 1 commit into
ghostty-org:mainfrom
jamesarch:fix/link-line-suffix
Open

Surface: open file paths with trailing :line[:col] suffixes#12995
jamesarch wants to merge 1 commit into
ghostty-org:mainfrom
jamesarch:fix/link-line-suffix

Conversation

@jamesarch

Copy link
Copy Markdown

Fixes a long-standing paper cut discussed extensively in #1972: clicking a
file path that carries a :line[:col] suffix (the standard output format
of most compilers, e.g. src/main.zig:42:10 from zig/clang, or
file.scala:47:70 as 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) and
try 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 -rn output. The full test suite was
also run on Linux (nix develop -c zig build test); no new failures
versus 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.

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>
@jamesarch jamesarch requested a review from a team as a code owner June 12, 2026 01:29
@jamesarch jamesarch closed this Jun 12, 2026
@jamesarch jamesarch reopened this Jun 12, 2026
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.

1 participant