-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: print target and package names formatted as file hyperlinks #15405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
this would also work on vte and konsole. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks you.
let mut shell = ws.gctx().shell(); | ||
for (name, manifest_path) in packages { | ||
let link = shell.err_file_hyperlink(manifest_path); | ||
writeln!(output, "{ITEM_INDENT}{link}{}{link:#}", name)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writeln!(output, "{ITEM_INDENT}{link}{}{link:#}", name)?; | |
writeln!(output, "{ITEM_INDENT}{link}{name}{link:#}")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On macOS:
- ghostty 1.0.1 opened the default editor.
- kitty 0.38.1 opened the default editor.
- iterm2 3.5.11 didn't render any link, even the old existing ones. Anyway, I tried
It tried to scp at the first attempt as we found in feat: Make browser links out of HTML file paths #12889 (comment). However in subsequent attempts it worked correctly and opened the default editor.
printf '\e]8;;file:///Users/user/foo/Cargo.toml\e\\This is a link\e]8;;\e\\'
- alacritty 0.15.1 didn't render any link just like iterm2. With the same test link above it worked and opened the default editor.
@ehuss would you happen to know why iterm2 doesn't really render those links? Finished
dev profile [unoptimized + debuginfo] target(s) in 0.04s
should also have a rendered link, but on iterm2 I didn't see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is a two-way door decision, and we already provide a way to disable the behavior, so the bar accepting this should be fairly low. However, as @ehuss has raised a concern of iterm2, I'd like to hear opinions from them :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, it is disabled via
Line 584 in c7be060
if std::env::var_os("TERM_PROGRAM").as_deref() == Some(std::ffi::OsStr::new("iTerm.app")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah and by turning hyperlink on always, both alacritty and iTerm2 work for me. I am going to merge this since iTerm2 is already always disabled.
Update cargo 12 commits in 0e93c5bf6a1d5ee7bc2af63d1afb16cd28793601..864f74d4eadcaea3eeda37a2e7f4d34de233d51e 2025-04-05 00:00:24 +0000 to 2025-04-11 20:37:27 +0000 - chore: Bump build-rs version (rust-lang/cargo#15421) - fix(build): Correct name of CARGO_CFG_FEATURE (rust-lang/cargo#15420) - Revert "fix(package): detect dirtiness for symlinks to submodule" (rust-lang/cargo#15419) - Improved error message when build-dir template var is invalid (rust-lang/cargo#15418) - Added validation for unmatched brackets in build-dir template (rust-lang/cargo#15414) - fix(package): detect dirtiness for symlinks to submodule (rust-lang/cargo#15416) - chore(deps): bump crossbeam-channel from 0.5.14 to 0.5.15 (rust-lang/cargo#15415) - docs(metadata): Added build_directory to cargo metadata documentation (rust-lang/cargo#15410) - Added symlink resolution for `workspace-path-hash` (rust-lang/cargo#15400) - feat: print target and package names formatted as file hyperlinks (rust-lang/cargo#15405) - docs(ref): Use better example value in `CARGO_CFG_TARGET_ABI` (rust-lang/cargo#15404) - chore: Bump cargo-util-schemas to 0.8.2 (rust-lang/cargo#15403) r? ghost
Resolves #15401
Here is an example of the feature in kitty
0.40.1
with the following config set in~/.config/kitty/kitty.conf
Tested on
uname -a
:Terminals tested with:
kitty
0.40.1
ghostty

1.1.4-6f1b22a-nix
alacritty

0.15.1
VScode's version
1.98
integrated terminal aka. xterm.jsThe following
cargo
invocations will have their output be modified by this change:In addition I have done a slight refactor to have the printed indent of targets and packages be the same by using a shared constant named
const ITEM_INDENT: &str = " ";
This is my first PR to the cargo codebase, so I am not familiar with what is expected in terms of test for a feature such as this.