misogi / vscode-ruby-rubocop

Rubocop extension for Visual Studio Code
https://marketplace.visualstudio.com/items/misogi.ruby-rubocop
MIT License
137 stars 68 forks source link

Formatting on save doesn't work: Extension 'ruby-rubocop' is configured as formatter but it cannot format 'Ruby'-files #166

Closed mdesantis closed 2 years ago

mdesantis commented 2 years ago

VSCode refuses to format files using this extension on file save.

When I save a file, the file is not formatted and in the status bar the following message is displayed for a brief time:

Extension 'ruby-rubocop' is configured as formatter but it cannot format 'Ruby'-files

If I format using format command instead (for example pressing Ctrl+Shift+I) it works properly and the file is formatted.

mdesantis commented 2 years ago

Troubleshooting this issue, I found that the following SO answer works:

For me the problem was with HTML files where formatting stopped working one day. I had Format On Save configured, which worked in all files except HTML.

I then realized that I experimentally set Format On Save Mode to modification instead of file and forgot about it. This had an effect of not formatting anything in HTML files, surprisingly not even my changes. Setting it back to file solved the issue.