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

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

Open
philomory opened this issue Aug 6, 2020 · 3 comments
Open

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

philomory opened this issue Aug 6, 2020 · 3 comments
Labels
bug Bug reports

Comments

@philomory
Copy link

philomory commented Aug 6, 2020

Your environment

  • vscode-ruby version: 0.27.0
  • Ruby version: 2.7.1p83
  • Ruby version manager (if any): uru
  • VS Code version: 1.47.2
  • Operating System: Windows 10
  • Using language server? (eg useLanguageServer is true in your configuration?): Yes

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

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
Copy link
Author

philomory commented Aug 6, 2020

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

reyou commented Sep 19, 2021

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

FYI I run following command as installation:

gem install rubocop

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

No branches or pull requests

3 participants