-
Notifications
You must be signed in to change notification settings - Fork 4.5k
terminal: Fix file paths links with URL escapes not being clickable #31830
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
terminal: Fix file paths links with URL escapes not being clickable #31830
Conversation
Updated PR with Release Notes. |
Thanks for this! Out of interest, what tools output filenames with url-encoding? Although it's unusual, Relatedly, in the case of |
Thanks for the response @ConradIrwin. The tool in question is The behavior of vscode is to support
It would make sense to me to have this only apply to Do you agree with that assessment? I could revise the patch accordingly if you do. |
Yes, that makes a lot more sense, thanks for clarifying! Looks like maybe the issue is here: zed/crates/terminal/src/terminal.rs Line 1037 in 3b34453
|
Later, |
I don't think so. I have two files: On the other hand, in a file URL the former can only be represented as |
3ae0d15
to
147f48d
Compare
@ConradIrwin I adjusted the implementation to keep it very focused on just decoding file:// urls, with a fallback to not decoding if there are unicode errors. I have tested this on all my use cases, and it does not affect paths that are NOT file:// Please check it out! |
147f48d
to
d91e6cf
Compare
I rebased on origin/main to resolve conflicts. |
d91e6cf
to
d49165a
Compare
Hey @ConradIrwin can we get this merged in? |
Sorry for dropping this! |
For #31827
URL Decoding Fix for Terminal File Path Clicking
Discussion
This change does not allow for paths that literally have
%XX
inside of them. If any such paths exist, they will fail to ctrl+click. A larger change would be needed to handle that.Problem
In the terminal, you could ctrl+click file paths to open them in the editor, but this didn't work when the paths contained URL-encoded characters (percent-encoded sequences like
%CE%BB
for Greek letter λ).Example Issue
dashboardλ.mts:3:8
dashboard%CE%BB.mts:3:8
The URL-encoded form
%CE%BB
represents the Greek letter λ (lambda), but the terminal wasn't decoding these sequences before trying to open the files.Solution
Added URL decoding functionality to the terminal path detection system:
crates/terminal/Cargo.toml
crates/terminal/src/terminal.rs
that:urlencoding::decode()
Code Changes
New Function
Modified PathLikeTarget Creation
The function is now called when creating
PathLikeTarget
instances:decode_file_path(path)
decode_file_path(&maybe_url_or_path)
Testing
Added comprehensive test coverage in
test_decode_file_path()
that verifies:Impact
This fix enables ctrl+click functionality for file paths containing non-ASCII characters that appear URL-encoded in terminal output, making the feature work consistently with tools that output percent-encoded file paths.
The change is backward compatible - all existing functionality continues to work unchanged, and the fix only activates when URL-encoded sequences are detected.
Release Notes:
%XX
escape sequences will now be properly decoded so that ctrl+click will open them