Skip to content

Implement UNC path mangling for OSC 7 via WSL#20094

Open
lhecker wants to merge 2 commits intomainfrom
dev/lhecker/osc-7-wsl
Open

Implement UNC path mangling for OSC 7 via WSL#20094
lhecker wants to merge 2 commits intomainfrom
dev/lhecker/osc-7-wsl

Conversation

@lhecker
Copy link
Copy Markdown
Member

@lhecker lhecker commented Apr 8, 2026

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
MangleStartingDirectoryForWSL doesn't properly
detect wsl.exe in a path with spaces. That's fixed now.

Validation Steps Performed

  • Navigate fish into some directory
  • Duplicate tab duplicates paths ✅

@lhecker lhecker added Area-VT Virtual Terminal sequence support Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Priority-3 A description (P3) labels Apr 8, 2026
}

// MUST NOT MANGLE
// Any wsl.exe is treated as a WSL profile, regardless of directory.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was somewhat trying to avoid this, just in case people did have other wsls dot exe.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this because of my C:\Program Files\WSL\wsl.exe profile.

{
// 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)");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add tests for the weird UNC path cases you added?

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"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AGH.

Copy link
Copy Markdown
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-VT Virtual Terminal sequence support Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) Product-Terminal The new Windows Terminal.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants