Skip to content

Open file:// links with a :line:col suffix at that position - #16440

Open
maxmilian wants to merge 1 commit into
warpdotdev:masterfrom
maxmilian:maxmilian/fix-3970-file-url-line-col
Open

maxmilian wants to merge 1 commit into
warpdotdev:masterfrom
maxmilian:maxmilian/fix-3970-file-url-line-col

Conversation

@maxmilian

@maxmilian maxmilian commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

Cmd-clicking (Ctrl-clicking on Linux/Windows) a file:// URL with a line/column suffix in terminal output does nothing. Gradle, kotlinc and other tools print locations in this form, for example:

e: file:///Users/me/project/src/Main.kt:35:24 Return type of 'clear' is not a subtype of ...

Root cause. The URL detector (urlocator) treats the whole token, :35:24 included, as one URL, and that takes priority over file-path detection. When the link is clicked, the GridHighlightedLink::Url arm in maybe_open_link (app/src/terminal/view.rs) and in open_highlighted_link (app/src/terminal/view/link_detection.rs, used by the "Open link" tooltip and context menu) passes the string straight to ctx.open_url. The OS looks for a file literally named Main.kt:35:24, finds none, and fails silently. A plain path such as /Users/me/project/src/Main.kt:35:24 already works, because file-path detection parses the suffix with CleanPathResult::with_line_and_column_number and opens it through open_file_path.

Fix. The URL arms, and the OSC 8 hyperlink path (open_hyperlink_uri, which is also what the HyperlinkClick action uses), now call a small open_url_link helper. It uses file_url_link_target to split a :line[:col] suffix off a file:// URL with the same CleanPathResult::with_line_and_column_number parser. Url::to_file_path decodes percent-encoding, so my%20notes.kt works. If the result is an existing file, it is opened through open_file_path, the same way a detected file path with a suffix is opened. Otherwise the URL is handed to the OS as before.

Kept narrow on purpose. Only URLs that have a suffix and resolve to an existing local file change behavior:

  • file:// URLs without a suffix still go to the OS, so echo file:///…/foo.txt + Cmd-click still opens the file in its default macOS app, as it does today.
  • Non-file schemes, file:// URLs with a host other than localhost, and paths that don't exist are unchanged. The host check runs before anything touches the filesystem, so a file://host/share/x.kt:1 link is never resolved as a UNC path on Windows.
  • If the URL as written already names an existing file (e.g. a file literally called notes:12), it is not reinterpreted as line 12 of notes.

When a suffixed file:// link is opened, it follows the same "open files with" editor setting as other file links with a line number, since that's the only way to honor the line and column.

This is a different code path from #11566, which handles file:// links in AI block output. The two changes don't overlap.

Linked Issue

Fixes #3970

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

  • cargo fmt -- --check
  • cargo clippy -p warp --all-targets --tests -- -D warnings
  • cargo nextest run -p warp --lib -E 'test(/terminal::view/)': 360/360 passed
  • I have manually tested my changes locally with ./script/run (see below)

New tests:

  • link_detection_tests.rs: file_url_link_target splits :35:24 and :35, decodes a percent-encoded space, accepts file://localhost/… (unix), returns None with no suffix, for non-file schemes, for missing files and for a remote host, and keeps a file literally named notes:12 (unix only).
  • view_tests.rs test_clicking_file_url_with_line_and_column_opens_file: prints a file://…/Main.kt:35:24 line into a block, checks that it is detected as one URL, then Cmd/Ctrl-clicks it through click_on_grid and asserts OpenFileWithTarget is emitted with the file and line 35, column 24.

All three behavior tests failed before the fix. The view test failed with no OpenFileWithTarget event because the URL went to open_url.

Screenshots / Videos

Same window, the same Gradle-style line (cat of a file containing e: file:///Users/maxmilian/c3970-demo/src/Main.kt:35:24 Return type of 'clear' ...), and the same synthesized Cmd-click on the link in both builds (./script/run bundles on macOS). "Open files with" is set to Warp in both.

  • master (21f06832): the link is underlined on hover, but Cmd-clicking it does nothing.
  • this PR (4f5cd75b): Cmd-clicking opens Main.kt in a Warp editor pane at line 35, with the cursor on the second clear.

With the default "Open files with: system default", the file is handed to the default app without a line number, the same as a plain Main.kt:35:24 path today.

Cmd-click on a file:// link with :35:24: master vs. this PR

master this PR
master this PR

Full recordings: master · this PR

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rtq1jctUbJMqEmwTxtZsTu

Cmd/Ctrl-clicking a URL like `file:///src/Main.kt:35:24` (as printed by Gradle and
other compilers) passed the whole string, suffix included, to the OS. No file has
that name, so nothing happened.

URL links (and OSC 8 hyperlinks) now go through `open_url_link`. When a `file://`
URL ends in a line/column suffix and the path without the suffix is an existing
file, it is opened like a detected file path, honoring the line and column.
Everything else, including `file://` URLs without a suffix, is still handed to
the OS as before.

Fixes warpdotdev#3970
@cla-bot cla-bot Bot added the cla-signed label Oct 13, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Oct 13, 2026
@maxmilian
maxmilian marked this pull request as ready for review October 27, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opening file link in format like file:///Users/someDir/someFile.kt:35:24 doesn't work - nothing happens on click

1 participant