ericclemmons / click-to-component

Option+Click React components in your browser to instantly open the source in VS Code
MIT License
1.82k stars 65 forks source link

Error when runs from WSL #27

Closed equiman closed 2 years ago

equiman commented 2 years ago

Paths are not working with WSL.

To Reproduce Steps to reproduce the behavior:

  1. Create a project with Vite inside WSL
  2. Opened it on VS Code using the Remote - WSL extension.
  3. Install click-to-component and add the configs
  4. Run de project
  5. Click on the secondary button and show the context menu with components image
  6. Click on component
  7. Show an error on VSCode image
  8. If click on [Yes] button, show this message image
  9. This is the message that shows the console in Chrome image

Expected behavior Open in VSCode without error

Desktop:

equiman commented 2 years ago

Maybe this information can help to solve it: https://github.com/microsoft/vscode/issues/99691

Instead of file need to use vscode-remote follow by the current distro and path/to/file

apostolos commented 2 years ago

If the WSL environment can be detected somehow, then the path should change to: \\ {WSLHostname} \ {Distro} \home\juanmartinez\DEIN\scrimba-react-vite\src\main.jsx

e.g. \\wsl.localhost\Ubuntu\home\juanmartinez\DEIN\scrimba-react-vite\src\main.jsx

If that's not possible, manually setting a prop should be an acceptable workaround.

equiman commented 2 years ago

Yes, it can be config like the editor="vscode-insiders" property. Maybe something like wsl="Ubuntu"

apostolos commented 2 years ago

The following both work and open in the correct workspace:

code --file-uri vscode-remote://wsl+Ubuntu/path/to/file
code --remote wsl+Ubuntu /path/to/file.js # guesses if it's a file or folder from extension

However click-to-component needs to work with vscode: URLs. Unfortunately AFAICT opening in the correct vscode-remote window is not yet possible but it's coming soon.

equiman commented 2 years ago

It's true. I've tested the URI with vscode-remote and doesn't launch the VSCode vscode-remote://Ubuntu/DEIN/scrimba-react-vite/src/App.jsx:11:9 image

With vscode ask on browser image

but can't open the file on VSCode. I've tried with this combinations: vscode://file\wsl.localhost\Ubuntu\home\juanmartinez\DEIN\scrimba-react-vite\src\App.jsx:11:9 vscode://\wsl.localhost\Ubuntu\home\juanmartinez\DEIN\scrimba-react-vite\src\App.jsx:11:9 vscode://file/wsl.localhost\Ubuntu\home\juanmartinez\DEIN\scrimba-react-vite\src\App.jsx:11:9 vscode://wsl.localhost/Ubuntu/home/juanmartinez/DEIN/scrimba-react-vite/src/App.jsx:11:9

apostolos commented 2 years ago

The following works for me, however it opens in a local vscode window instead of the correct vscode-remote workspace:

start vscode://file/$wsl/wsl.localhost/Ubuntu/path/to/file.jsx
equiman commented 2 years ago

I've copied the path from File Explorer image

Add put on browser address bar like this: vscode://file//wsl$/Ubuntu/home/juanmartinez/DEIN/scrimba-react-vite/src/App.jsx:11:9

But happen me the same to you, open it another 'local' instance, instead 'wsl-remote' image

Seems to be that we are gonna need to wait until vscode-remote:// was supported on the browser 😥

equiman commented 2 years ago

According to this documentation: our-triaging-flow. Needs at least 20 community votes, and have 18.

So we need another 2 votes more to reach it.

map

ericclemmons commented 2 years ago

I've voted for https://github.com/microsoft/vscode-remote-release/issues/4779!

In the meantime, I think we're forced to close this issue **until the browser supports a ${protocol}://... that this library can window.open(url) with :(

When that's ready, instead of editor there'll be a prop like sourceToURL({ editor, source }): string that you can use to craft a working URL.

equiman commented 2 years ago

Hi @ericclemmons, seems to be this issue finally can be solved.

vscode://vscode-remote/wsl+[host]/[path/to/file]:[line]:[col]
vscode://vscode-remote/ssh-remote+[host]/[path/to/file]:[line]:[col]

I've tested it from the browser:

vscode://vscode-remote/wsl+ubuntu/home/juanmartinez/Developer/DEIN/swpm/src/swpm.js:3

And it will open the project using WSL on image