yyx990803 / launch-editor

Open file in editor from Node.js.
MIT License
576 stars 65 forks source link

Remote support #72

Open martinszeltins opened 5 months ago

martinszeltins commented 5 months ago

When working from home, I connect to my office computer using vscode Remote Development feature. Currently the launch-editor uses -r -g arguments to open vscode but when working with remote development we need a different set of arguments. Otherwise it tries to find and open the file on the local machine (which does not exist)

https://github.com/yyx990803/launch-editor/blob/master/packages/launch-editor/get-args.js#L43

    case 'code':
    case 'Code':
    case 'code-insiders':
    case 'Code - Insiders':
    case 'codium':
    case 'vscodium':
    case 'VSCodium':
      return ['-r', '-g', `${fileName}:${lineNumber}:${columnNumber}`]

When working with remote development the arguments need to be these:

$ code -r --remote ssh-remote+192.168.0.17 -g /home/martin/nuxt/components/HelloWorld.vue:3

The 192.168.0.17 is the name of the host found in ~/.ssh/config. I guess this part would need to be configurable or passed as query arg like /__open-in-editor?file=src/main.js&remote=NAME_OF_REMOTE

The --remote option wasn't well documented, it does not show up when you type code --help but I found it on this issue and it does indeed work - https://github.com/microsoft/vscode-remote-release/issues/5083

HobaiRiku commented 2 months ago

I am a fan of using this feature, and I also work in vscode remote, after learning from @martinszeltins 's comment and some related issue among the projects, I wrote a simple solution call-me-back to make this work, it is kind of workaround and dirty, but I use this for my daily development now.

The main is to set up a tunnel to remote and change the editor to a script in which the remote can execute command in the right local machine

My opinion:

  1. launch-editor will not work in either vscode remote integrated terminal or directly run in remote host, because the code should be not found in the subprocess or the code is not the local one which launch-editor assumes.
  2. other thinking (including wsl) is in my solution repo's readme.

I hope this can help someone who is interested in this feature.

Related: