castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
424 stars 25 forks source link

Server fails to launch due to bad arguments; extension can't handle user profile paths with spaces in the username? #20

Closed WToorenburghIntiveo closed 6 years ago

WToorenburghIntiveo commented 6 years ago

Hey there,

OS: Windows 10 Pro 1709 build 16299.192 VSCode Version: 1.19.3 Solargraph extension: 0.11.1 Possibly relevant extensions: Ruby extension: rebornix.ruby version 0.16.0 Chef Extension for Visual Studio Code Pendrica.chef version 0.6.4 All extensions:

code --list-extensions
AlanWalk.markdown-toc
bierner.markdown-preview-github-styles
burtlo.inspec
castwide.solargraph
codezombiech.gitignore
DavidAnson.vscode-markdownlint
donjayamanne.githistory
DotJoshJohnson.xml
felipecaputo.git-project-manager
felixfbecker.php-intellisense
formulahendry.code-runner
hangxingliu.vscode-nginx-conf-hint
hnw.vscode-auto-open-markdown-preview
irvinlim.language-modsecurity
jirkafajfr.vscode-kitchen
le0zh.vscode-regexp-preivew
mikestead.dotenv
ms-vscode.PowerShell
Pendrica.chef
PeterJausovec.vscode-docker
rebornix.Ruby
robertohuertasm.vscode-icons
shanoor.vscode-nginx
ziyasal.vscode-open-in-github

I've been trying to get your extension to work, and I think I found a bug. Entering Ctrl+Space to show suggestions was showing a Loading... prompt that would never finish. When I opened Process Explorer to see if VSCode had a Ruby process running, there was nothing. Running Solargraph: Restart Solargraph showed a Ruby process running for a split second, then exiting.

To make sure the Gem was working, I ran solargraph server -p 0 in a Powershell prompt (having seen you suggest that as a method for testing in another issue), and pointed my browser to the localhost port. I saw the "Sinatra doesn’t know this ditty.", and corresponding output in the server log in my terminal, so that confirmed there wasn't anything the matter with the Gem.

My username has a space in it, so my profile path does as well ("C:\Users\<Firstname> <Lastname>\..."). In the dev console, when running the Solargraph: Restart Solargraph command, this error is thrown: [Extension Host] ERROR: "solargraph server" was called with arguments ["<Lastname>\\.vscode\\extensions\\castwide.solargraph-0.11.1/views"] Usage: "solargraph server". It seems like the command is getting split by the space in my profile folder name?

Let me know if there's any further context I can provide!

WToorenburghIntiveo commented 6 years ago

I did a little digging through the code, and I found this line: https://github.com/castwide/vscode-solargraph/blob/master/src/extension.ts#L78

config.viewsPath = vscode.extensions.getExtension('castwide.solargraph').extensionPath + '/views';

My suspicion is that it needs to be wrapped in double quotes, like so:

config.viewsPath = "${vscode.extensions.getExtension('castwide.solargraph').extensionPath}/views";

I know pretty much nothing about typescript, so forgive me if I am barking up the wrong tree with this.

castwide commented 6 years ago

Thanks for the report. I'll fix it in the solargraph-utils package to ensure that command-line arguments are always escaped. Seeing as how the function accepts arguments as an array, I'm a little surprised it isn't already being done.

castwide commented 6 years ago

Version 0.11.3 of the extension should fix this issue.

WToorenburghIntiveo commented 6 years ago

Perfect! Suggestions are now working. Thank you for such a quick response!