rubyide / vscode-ruby

Provides Ruby language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby
MIT License
1.26k stars 285 forks source link

Format with RuboCop adds line breaks between every line of code #644

Open philomory opened 4 years ago

philomory commented 4 years ago

Your environment

Expected behavior

When I run the Format Document command with an already-valid document, no changes should be made to the document.

Actual behavior

Before running Format Document: image

After running Format Document: image

I thought this might be because I'm on Windows but using LF rather than CRLF for line endings (in both VS Code and .rubocop.yml), but, switching everything to CRLF didn't actually help.

This feels similar to some weird stuff I've seen happen when using pipes in Powershell, but I haven't dug around into the extension code to see if we're actually doing that on Windows or not.

wingrunr21 commented 4 years ago

Interesting. Using cmd vs powershell depends on what your default shell is set to. Have you turned on verbose logging and looked at the server logs?

philomory commented 4 years ago

@wingrunr21 Sorry if I'm being thick, but, how do you turn on verbose logging? I can't find anything about that in either the extension documentation or in VSCode's documentation. Certainly I've checked the Output pane, but all it says is

Format: executing rubocop.bat -s c:\path\to\dummy.rb -a...
undefined

EDIT: That said, changing my default shell from Powershell to CMD, and then reloading the window, does result in the Format Document command working correctly. So, this does seem to be specific to Powershell and its confusing line break behavior (as I understand it, when you pipe a multi-line block of text around in Powershell, what actually gets passed around is an array of single-line strings; they only get 'joined' back into a single multi-line block when being displayed, or piped to an external tool).

reyou commented 3 years ago

I think this needs to be investigated. A major issue on Windows / VS Code.

FYI I run following command as installation:

gem install rubocop