fix(explorer): reveal files in the Windows Explorer when the host runs under WSL - #575
Open
Kerwin75631591 wants to merge 1 commit into
Open
fix(explorer): reveal files in the Windows Explorer when the host runs under WSL#575Kerwin75631591 wants to merge 1 commit into
Kerwin75631591 wants to merge 1 commit into
Conversation
…s under WSL The file-tree 'Show in folder' action spawns xdg-open on Linux, but a WSL host has no Linux file manager (and usually no xdg-open), so reveal silently did nothing. Detect WSL (WSL_DISTRO_NAME or /proc/version) and hand reveal to explorer.exe with a wslpath -w translated /select,<path> instead, keeping the Windows dirs on PATH for interop. Command builders stay pure (wsl flag + translator injected); non-WSL Linux behavior unchanged.
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.
fix(explorer): reveal files in the Windows Explorer when the host runs under WSL
Problem
The file-tree context menu action "Show in folder" (the built-in Explorer open-with target, kind
reveal) does nothing when DSH runs inside WSL2 (e.g.dsh webhosted in Ubuntu on WSL, UI opened from the Windows browser):process.platformis'linux', so the default branch ofrevealCommandspawnsxdg-open <parent-dir>.xdg-open(spawnfails with ENOENT, which the route deliberately swallows), and even whenxdg-openexists it cannot open the Windows desktop's Explorer.win32/darwinbranches were already correct; only the Linux default branch missed the WSL case.)Change
Detect the WSL runtime (
WSL_DISTRO_NAMEenv or/proc/versioncontainingmicrosoft) and, for reveal actions, hand the path to the Windows Explorer exactly like thewin32branch:wslpath -w—/mnt/c/...becomesC:\..., Linux-filesystem paths become\\wsl.localhost\<distro>\....explorer.exe /select,<translated>so the file/directory is selected in Explorer..exeopener under WSL, extend the childPATHwith/mnt/c/WINDOWS(+ System32) so Windows interop resolves even for hosts started with a slimPATH.Plain-Linux and native-macOS/Windows behavior is unchanged (
revealCommandstill defaults to the non-WSLxdg-openbranch; URL open-with targets are untouched — out of scope).Design notes
wsland the path translator are injected parameters, defaulting to non-WSL;launchExternalis the only place that consultsisWslRuntime()and the realwslpath-based translator.wslpath).Test plan
tests/open-external.spec.tscovers the WSL reveal branch (injected translator).revealCommandlinux/win32/darwin tests unchanged and still green.Ubuntu-24.04, DSH 0.1.2 host in WSL): right-click a workspace file → Show in folder now opens Windows Explorer with the file selected (Linux-fs and/mnt/cpaths both verified).