Skip to content
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

Improve file:// hyperlinks support - local/remote hostname #14116

Open
ltrzesniewski opened this issue Oct 2, 2022 · 9 comments
Open

Improve file:// hyperlinks support - local/remote hostname #14116

ltrzesniewski opened this issue Oct 2, 2022 · 9 comments
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Priority-3 A description (P3) Product-Terminal The new Windows Terminal.
Milestone

Comments

@ltrzesniewski
Copy link

ltrzesniewski commented Oct 2, 2022

Description of the new feature/enhancement

Currently, Windows Terminal supports the following file:// URI patterns:

  • file:///C:/SomeDir/SomeFile.txt
  • file://localhost/C:/SomeDir/SomeFile.txt

The following patterns are rejected with a "This link type is currently not supported" message:

  • file://wsl$/Ubuntu/SomeDir/SomeFile.txt
  • file://remote_host/SomeDir/SomeFile.txt
  • file://local_hostname/SomeDir/SomeFile.txt

Please add support for these cases. Note that the hyperlinks (OSC 8) spec requests for the hostname to be present in file URIs.

Proposed technical implementation details

The following justification is provided in the code:

// TODO: by the OSC 8 spec, if a hostname (other than localhost) is provided, we _should_ be
// comparing that value against what is returned by GetComputerNameExW and making sure they match.
// However, ShellExecute does not seem to be happy with file URIs of the form
// file://{hostname}/path/to/file.ext
// and so while we could do the hostname matching, we do not know how to actually open the URI
// if its given in that form. So for now we ignore all hostnames other than localhost

After testing with ShellExecuteEx (more precisely with Process.Start with UseShellExecute in .NET), I noticed the following:

  • Remote hostnames (including wsl$) are supported just fine by the shell
  • The local hostname results in the following error: "The system cannot find the file specified"

Therefore, I think the Windows Terminal should:

  • Substitute the hostname in the URI with localhost if it happens to match the local hostname
  • Maybe also support the FQDN?
  • Try to open URIs with a remote hostname as-is

This relates to #7699 and #5001.

See also the discussion in BurntSushi/ripgrep#665 for the problems this feature would solve.

Another example of a really useful usage this would enable would be oh-my-posh WSL links:

image

@ltrzesniewski ltrzesniewski added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Oct 2, 2022
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Oct 2, 2022
@ltrzesniewski
Copy link
Author

ltrzesniewski commented Oct 3, 2022

As a bonus point, if Windows Terminal could also strip the fragment #xxx and query ?xxx parts of a file:// URI, that would be helpful for interoperability.

The Windows shell cannot handle those, but other terminals may use them for opening a text file at a given line for instance (e.g. kitty will interpret a #42 fragment as a line number). It would be nice if those links could work in WT as well, although with more limited functionality.

See the drama in BurntSushi/ripgrep#2322 if you want more context.

@zadjii

This comment was marked as off-topic.

@carlos-zamora carlos-zamora added the Needs-Attention The core contributors need to come back around and look at this ASAP. label Mar 22, 2023
@zadjii-msft zadjii-msft assigned DHowett and unassigned DHowett May 3, 2023
@ShayBox

This comment was marked as off-topic.

@j4james

This comment was marked as off-topic.

@ltrzesniewski

This comment was marked as off-topic.

@zadjii-msft

This comment was marked as off-topic.

@ltrzesniewski

This comment was marked as off-topic.

@DHowett
Copy link
Member

DHowett commented Jul 19, 2023

I didn't intend to let this one marinate for so long. After reading it initially, I let it grow into this huge and concerning feature request... but it really isn't that.

This is in line with the work we need to do to polish up hyperlinks in #8849. I'll keep it separate for now, but it's along the path we'll need to take to differentiate what we (1) detect and (2) launch and make those configurable.

@DHowett DHowett added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. Priority-3 A description (P3) and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Jul 19, 2023
@DHowett DHowett added this to the Backlog milestone Jul 19, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot removed Needs-Tag-Fix Doesn't match tag requirements labels Jul 19, 2023
@carlos-zamora carlos-zamora removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Aug 2, 2023
@Diti
Copy link

Diti commented Sep 7, 2024

The hyperlinks produced by eza (with eza --hyperlink /var/tmp for instance) in WSL also don’t work. Windows Terminal doesn’t seem to be aware it is in a WSL session and won’t transform the links to something like file://wsl$/WLinux/var/tmp. So clicking on the “regular” links have no effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Priority-3 A description (P3) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

8 participants