Implement UNC path mangling for OSC 7 via WSL#20094
Open
Conversation
lhecker
commented
Apr 8, 2026
DHowett
reviewed
Apr 8, 2026
DHowett
reviewed
Apr 8, 2026
| } | ||
|
|
||
| // MUST NOT MANGLE | ||
| // Any wsl.exe is treated as a WSL profile, regardless of directory. |
Member
There was a problem hiding this comment.
i was somewhat trying to avoid this, just in case people did have other wsls dot exe.
Member
Author
There was a problem hiding this comment.
I did this because of my C:\Program Files\WSL\wsl.exe profile.
DHowett
reviewed
Apr 8, 2026
| { | ||
| // Test for GH#11994 - make sure `//wsl$/` paths get mangled back to | ||
| // `\\wsl$\`, to workaround a potential bug in `wsl --cd` | ||
| auto [commandline, path] = MangleStartingDirectoryForWSL(LR"(wsl -d Ubuntu)", LR"(//wsl$/Ubuntu/home/user)"); |
Member
There was a problem hiding this comment.
can you add tests for the weird UNC path cases you added?
DHowett
reviewed
Apr 8, 2026
| mangledDirectory = std::filesystem::path{ startingDirectory }.make_preferred().wstring(); | ||
| } | ||
| std::wstring dir{ startingDirectory }; | ||
| if (til::starts_with(dir, L"//wsl$") || til::starts_with(dir, L"//wsl.localhost")) |
Member
There was a problem hiding this comment.
we still need to support paths that start with \\wsl$ and \\wsl.localhost without mangling them as in line R1161 :)
The tests are failing because they just straight up assume \\wsl.localhost\Ubuntu\foo exists without checking for it. It probably passes on your machine after launching the ubuntu distro because you have a real share accessible via \\wsl.localhost\Ubuntu.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a followup of #20019 wich makes it possible
to duplicate WSL tabs with e.g. fish-shell.
The PR is somewhat large because I found that the
MangleStartingDirectoryForWSLdoesn't properlydetect
wsl.exein a path with spaces. That's fixed now.Validation Steps Performed