Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add skeleton code for OSC 7 #8921
Add skeleton code for OSC 7 #8921
Changes from 2 commits
c435f90
54ec9bb
398e6cb
4b9b417
44d14b7
a90da70
5ff9e35
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This is debatable. For a Unix path
file://localhost/usr/local/bin
, the correct interpretation would behostname = localhost, path = /usr/local/bin
. For a Windows pathfile://WIN-DESKTOP-1/D:
, the correct interpretation would behostname = WIN-DESKTOP-1, path = D:
. The difference makes the detection of/
indeterministic.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 found this during messing around fish shell, which have builtin OSC 7 support. The path fish emits is the form of
file://localhost/usr/local/bin
. BothiTerm2
andterminal.app
handles the path perfectly.CC @j4james @TBBle for awareness.
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.
The FD standard specifies
file://localhost/some/path
orfile:///some/path
but allowsfile://some/path
for bug-compatiblity, if I recall the research from the other OSC 7 PR. I thinkfile://myhost/some/path
was messy, because if I recall correctly, the FD spec would be looking for/myhost/some/path
on the local system (file://
can only refer to local system file paths in the FD spec, so this falls into the back-compat processing) while on Windows,file://myhost/some/path
means\\myhost\some\path
, i.e. a UNC path using the hostname as the hostname.Windows is happy with
file://localhost/C:/games
andfile:///C:/games
and takes them both as 'local' when asked via "Run".So
file://WIN-DESKTOP-1/D:
would be very likely to be invalid, as I don't think a CIFS share can have:
in its name. (I could be wrong. Either way, it's certainly not what the user intended).I think my suggestion at the time was to receive a URL, and if the hostname was the local system name, replace it with
localhost
before letting any Windows APIs see it.It all gets super-messy with WSL though, as
file://wsl$/Ubuntu/home/users
is the correct file URL for/home/users
in the Ubuntu WSL instance, but there was definitely strong objection to usingfile:$(wslpath -m ${PWD})
to generate this, in favour of some magic at another level so that the WSL environment could ignore that it was in WSL when generating OSC 7.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.
All that said, why don't we have a URL parser around already? Do we need to recreate URL parsing by hand?
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.
Ideally this parsing needs to be specific to the target profile I think. If it's a Windows path, then you need to check for paths starting with
/C:
or/C|
, drop the leading/
and potentially replace|
wth:
(although I wouldn't be too concerned about the latter case).And of course if the target profile is something like WSL or Cygwin, then we've got that additional translation that's needed to convert the path into a format that the profile will accept. So maybe the Windows-specific quirks could be handled at that level too. And in that case, it's probably OK to just return
/C:\path
at this point.I really wouldn't worry too much about UNC paths though. If there is a shell or application that's sending us a UNC path (and I think that in itself is unlikely), it's almost certainly going to be be in the form
file://hostname/\\UNC\path
, which could be handled in much the same way as the/C:\path
format.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.
Originally I just want to add the skeleton code and NOT touching things that are profile-related. That is blocked by the future implementation of profile-aware tabs. Also it will complicate the PR too much. But now after reading you guys comments I realize my intention seems unrealistic.
@j4james I agree with you. But I’m not comfortable doing profile-related thing in the low level VT code. The VT parser should not care about the environment, right? Also I honestly do not think we can detect the profiles here technically.
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, I'm totally in agreement with you about the leaving the profile-related stuff out of this. That's why I was saying you could probably ignore the Windows quirks at this level too, and just return the path component as is. Then whoever it handling that path at the higher levels can worry about how to interpret 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.
Oh OK, now I understand what you mean. Thanks for the inspiration!
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.
@TBBle I tried to implement the backward combability thing regarding
file:/<path>
. But I'm lost at how can I tell iffile://usr/local/bin
meanshostname ="", path = "/usr/local/bin"
orhostname = "usr", path = "/local/bin
. I found this when I was trying to come up with the test cases, and I failed to find a solution.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 think that exact point is where the last OSC 7 attempt got stuck as well: Is the
file://
URL we're receiving here per the FD spec, or per the Windows spec?In the end, we can't support both, because as you've noted, they have different semantics for overlapping cases.
We could perhaps support the common subset by ignoring the FD spec's back-compat parse (
file://usr/local/bin
=>/usr/local/bin
), and ignoring the Windows remote-host parse (file://server/share/file
=>\\server\share\file
), and hence having unambiguous parsing for those URLs we don't reject as "wrong host" (FD) or "remote host" (Windows), although that does block using OSC 7 when my shell's CWD is a remote (UNC) path, which includes WSL mounts accessed from the host.Whichever format you choose, I can't see a way to avoid making some or all shells aware that they're on Windows, without already-rejected hacking at process information to determine details about the virtualised filesystem they are reporting paths against. The proposal is to punt that to a higher layer, but I don't think a higher layer can do anything differently on this point.