Closed akirataguchi115 closed 6 months ago
Thank you for the bug report! This is indeed annoying, but it's not coming from the server. We don't handle this in onTypeFormatting
, this is coming from the grammar file in the VS Code extension.
I'll transfer the issue to that repo.
Not sure if its the same issue or only related, but I've found some other auto indentation issues when using Shopify's Ruby LSP extension. In addition to the original problem around include
being auto-indented as soon as you type in
(probably because it tries to detect it as the pattern matching keyword), I've also noticed inconsistent behavior with do...end
blocks. For example, in RSpec tests, different things happen with different kinds of blocks:
describe "an rspec test group" do
# does not properly increase indentation after entering the newline
let(:variable) do
# properly increases indentation after entering the newline
I can't really reproduce the describe block indentation issue. If I do it, I get the right indentation. Do you have any other Ruby related extensions? Also, are you using our recommended configurations?
Weird… I can't reproduce it anymore either 🤔 Totally willing to chalk it up to some fluke or strange interaction, sorry for the misdirection 😅
I'll try to reproduce this in the next 48 hours.
I am able to reproduce the bug. Editing the Code snippet to be more readable as the issue template messed it up.
I can confirm that the wrong auto indent already happens, as stated above, when typing "in".
I can also reproduce the following bug mentioned above:
describe "an rspec test group" do
# does not properly increase indentation after entering the newline
let(:variable) do
# properly increases indentation after entering the newline
The bug still happens after setting the recommended configurations and disabling ruby-rubocop
extension.
Are you using Copilot?
I can reproduce if that's enabled:
Great to know that you can reproduce it. I'm not using Copilot though.
We created a fix for the in
and the when
problem. For the indentation after the automatic on type formatting end
completions, I believe that the language configuration decrease rules are getting triggered when we insert it, which messes up the indentation.
The way to fix it is to add the correct indentation from the on type formatting request in the server.
For anyone else that finds this Issue and wonders "whats going on?" since there wasn't a link. 🤣 LSP will correct indentation on format, but... its still rather annoying. @vinistock opened a PR for the underlying issue in VS Code itself. (many thanks btw. I swear this worked at some point in the past ... many months, but the rules in vs code say its been this way since 2021 🤷)
Will that fix the issue in VSCode? It seems like that's against the now-deprecated default Ruby extension, and everybody now is being told to install Shopify's Ruby LSP extension
The change above corresponds to the built-in Ruby Language Basics extension:
The extension that was deprecated was https://github.com/rubyide/vscode-ruby
Ruby version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
Code snippet
Description
Paste the code snippet. Remove line 2. Start writing the same line starting with "include" with indentation already input there like in the snippet.
Expected output
The indentation holds and the include gets typed correctly there.
Actual output
Ruby LSP indents the "include" backwards as if the include shouldn't be indented.
According to the Official Ruby API
include
should be indented: https://docs.ruby-lang.org/en/master/Module.html