Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Selection formatting broken with rubocop and standardrb #434

Closed
solnic opened this issue Feb 21, 2019 · 11 comments
Closed

Selection formatting broken with rubocop and standardrb #434

solnic opened this issue Feb 21, 2019 · 11 comments
Assignees
Labels
bug Bug reports

Comments

@solnic
Copy link

solnic commented Feb 21, 2019

Your environment

  • vscode-ruby version: 0.22.0
  • Ruby version: 2.4.1
  • Ruby version manager (if any): chruby
  • VS Code version: 1.31.1
  • Operating System: macOS Mojave
  • Using language server? yes

Expected behavior

When 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.

Actual behavior

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
@wingrunr21
Copy link
Collaborator

How are those installed? Globally? Does that exact command work in a console?

@solnic
Copy link
Author

solnic commented Feb 21, 2019

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.

@wingrunr21
Copy link
Collaborator

-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?

@wingrunr21 wingrunr21 added the bug Bug reports label Feb 21, 2019
@wingrunr21 wingrunr21 self-assigned this Feb 21, 2019
@solnic
Copy link
Author

solnic commented Feb 21, 2019

If you fix all the errors in a file does the formatting work?

Yes!

@wingrunr21
Copy link
Collaborator

ok great. This is definitely a bug. I'll get it fixed!

@wingrunr21
Copy link
Collaborator

v0.22.2 should fix this

@bjeanes
Copy link

bjeanes commented Feb 25, 2019

I'm on 0.22.2 and I still get an error about no selection formatter being defined. Am I missing a configuration option?

@solnic
Copy link
Author

solnic commented Feb 25, 2019

@bjeanes it only works with the language server enabled

@bjeanes
Copy link

bjeanes commented Feb 25, 2019

Turning that on gets rid of the error message, but instead it just doesn't indent, silently. :|

@solnic
Copy link
Author

solnic commented Feb 25, 2019

I can confirm that it doesn't format, both rubocop and standard. Nothing happens, no errors in the output.

@wingrunr21
Copy link
Collaborator

Can you post screenshots of your highlighting, logs, and config?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug reports
Projects
None yet
Development

No branches or pull requests

3 participants