sadesyllas / vscode-workspace-switcher

Easily switch between workspaces
GNU General Public License v3.0
28 stars 8 forks source link

bad option: -n #10

Closed ErikMartensson closed 6 years ago

ErikMartensson commented 6 years ago

Whenever I try to switch workspace, into a new window, I get this error message:

Command failed: code -n "C:\Users\Erik\Cygwin home\repos\4.0\project.code-workspace" code: bad option: -n

If I instead try to switch workspace into the same window, I get another error message:

Command failed: code -r "C:\Users\Erik\Cygwin home\repos\4.0\project.code-workspace" C:\Users\Erik\.babun\cygwin\home\Erik\repos\4.0\project.code-workspace:2 "folders": [ ^ SyntaxError: Unexpected token : at createScript (vm.js:53:10) at Object.runInThisContext (vm.js:95:10) at Module._compile (module.js:543:28) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) at Function.Module._preloadModules (module.js:665:12) at preloadModules (bootstrap_node.js:404:38)

Code.exe is available in my $PATH and I can run these commands from CMD with no problem.

Specs Windows 10 64-bit vscode-workspace-switcher 1.5.1

Visual Studio Code Version 1.21.1 Commit 79b44aa704ce542d8ca4a3cc44cfca566e7720f1 Date 2018-03-14T14:46:47.128Z Shell 1.7.9 Renderer 58.0.3029.110 Node 7.9.0 Architecture x64

ghost commented 6 years ago

Also getting the same issue:

Command failed: code -r "C:\Users\LeeTaylor\vscode projects\schools.code-workspace"
C:\Users\LeeTaylor\vscode projects\schools.code-workspace:2
    "folders": [
             ^
SyntaxError: Unexpected token :
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at Function.Module._preloadModules (module.js:665:12)
    at preloadModules (bootstrap_node.js:404:38)

If I just run the following command in my terminal it all works fine:

code -r "C:\Users\LeeTaylor\vscode projects\schools.code-workspace"
ErikMartensson commented 6 years ago

@LTTaylor I found another way to switch workspaces, without this extension. Maybe you know about it already, but I wanted to share anyway.

Ctrl+R Opens up a list of recently used workspaces. And holding Ctrl while pressing enter will open that workspace in a new window.

This built in functionality doesn't replace this extension completely, since it only shows recent workspaces.

sadesyllas commented 6 years ago

@LTTaylor + @ErikMartensson, this is a known issue with windows.

In short, the reason for this is that when called from within VS Code, the shell cannot find the correct executable and instead, it runs something else.

The implemented solution for this is to provide the path to the executable, in your configuration, like so: "vscodeWorkspaceSwitcher.codeExecutable" : "C:\\Program Files (x86)\\Microsoft VS Code\\bin\\code.cmd"

For more information, please, take a look at #5.