vscode-ruby version: 0.22.0When I select one or more lines in a file and execute "Format Selection" command, it should use the configured tool (rubocop or standardrb) to format selected part of the file.
FWIW - rufo does work and "Format Document" command works fine too, regardless of the formatting tool.
Getting exceptions in the console like this:
rubocop:
[Error - 11:50:39 AM] Request textDocument/rangeFormatting failed.
Message: Request textDocument/rangeFormatting failed with message:
unable to execute rubocop -s /absolute/path/to/the/file.rb -a:
Error: Failed with exit code: 1 - unknown error
Code: -32603
standardb:
Format: executing standardrb -s /absolute/path/to/the/file.rb --fix...
[Error - 11:52:44 AM] Request textDocument/rangeFormatting failed.
Message: Request textDocument/rangeFormatting failed with message:
unable to execute standardrb -s /absolute/path/to/the/file.rb --fix:
Error: Failed with exit code: 1 - unknown error
How are those installed? Globally? Does that exact command work in a console?
Globally, not part of the Gemfile. Notice that rufo works fine, it's installed globally as well. When I run the command in the console nothing happens. I'm not sure if using -s option is correct, it's for reading from STDIN but we're passing a path to a file.
-s is correct
Looks like the 1 exit code is what's causing that. I must have broken that when doing the error handling. If you fix all the errors in a file does the formatting work?
If you fix all the errors in a file does the formatting work?
Yes!
ok great. This is definitely a bug. I'll get it fixed!
v0.22.2 should fix this
I'm on 0.22.2 and I still get an error about no selection formatter being defined. Am I missing a configuration option?
@bjeanes it only works with the language server enabled
Turning that on gets rid of the error message, but instead it just doesn't indent, silently. :|
I can confirm that it doesn't format, both rubocop and standard. Nothing happens, no errors in the output.
Can you post screenshots of your highlighting, logs, and config?
Most helpful comment
ok great. This is definitely a bug. I'll get it fixed!