-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
New misspellings found, please review:
To accept these changes, run the following commands
✏️ Contributor please read thisBy default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
See the 🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The :check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉
|
} | ||
|
||
hostname = string.substr(current, nextSlash - current); | ||
current = nextSlash + 1; |
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 be hostname = localhost, path = /usr/local/bin
. For a Windows path file://WIN-DESKTOP-1/D:
, the correct interpretation would be hostname = 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.
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
or file:///some/path
but allows file://some/path
for bug-compatiblity, if I recall the research from the other OSC 7 PR. I think file://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
and file:///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 using file:$(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 if file://usr/local/bin
means hostname ="", path = "/usr/local/bin"
or hostname = "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.
There is an URL parser in winrt. Down here the code need to be Win7 clean, which means i cannot use the winrt URL class. I do not know othet classes that can be used here. Perhaps one of the core devs will have a idea.
获取 Outlook for Android<https://aka.ms/ghei36>
|
Do we need to support OSC7 on WIn7 though? I'm not so sure that any of the VT sequences are being used through Visual Studio on Win7 unless they were implemented in Terminal itself (not openconsole/conhost). @javierdlg might know if and which VT sequences are utilized by Visual Studio and if this particular sequence should be supported (for Win7 specifically). |
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.
Okay this might be annoying, but I think we should add the tests for OutputStateMachineEngine::_ParseFileUri
now. There's some weird logic that goes on in that function, and I think it'd be helpful to have automated tests for those cases to show what we do and do not accept.
This is a reasonable request. I'll try to add some later. I'm happy that I can use |
@WSLUser It isn't really about the usability of OSC 7 on Windows 7. It's about the code can be successfully compiled for Windows 7 & for more Windows editions inside Microsoft. I do not know all the details. That's why I consulted the experts on this. |
hostname = string.substr(current, nextSlash - current); | ||
current = nextSlash; | ||
std::wstring _path = std::wstring(string.substr(current, std::wstring::npos)); | ||
if (SUCCEEDED(UrlUnescapeInPlace(_path.data(), URL_ESCAPE_AS_UTF8 | URL_DONT_UNESCAPE_EXTRA_INFO))) |
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 URL_UNESCAPE_AS_UTF8
is only available on Win8+, where as URL_ESCAPE_AS_UTF8
is available on Win7+. And we have:
#define URL_UNESCAPE_AS_UTF8 URL_ESCAPE_AS_UTF8
But I'm not sure the flag will do anything on Win7, though.
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 the flag URL_UNESCAPE_AS_UTF8
is very important since URLs escaped by Linux will require this to be correctly decoded. See test cases below.
@zadjii-msft Mind taking a look at my test cases? |
We do currently support Win7 for VS and won't be dropping support anytime soon, so I'd prefer to keep that support :) |
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'm gonna block this so I can get my concerns written out. It's not about any specific thing in the code -- just the overall approach. Need a little bit.
Sure. Take the time. This is just a prototype kinda work. Didn't really expect this to be shipped or used any time soon. |
Stale PR. Closed. |
Summary of the Pull Request
This adds the skeleton code for OSC 7 to the Windows Terminal. No actual functionality is implemented yet,
References
Related: #3158
Supersedes: #7668
Supports: #8214
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed