Vscode: AutoIndent clears autocompletion buffer, 'end' becomes 'def' in Ruby

Created on 21 Jun 2017  路  19Comments  路  Source: microsoft/vscode

  • VSCode Version: Code - Insiders 1.14.0-insider (a49a42680a4269b79c4e80f6d754bbded03a0593, 2017-06-21T05:07:22.267Z)
  • OS Version: Darwin x64 16.6.0
  • Extensions:

Extension|Author (truncated)|Version
---|---|---
Ruby|reb|0.12.1


GIF for better explanation:

out

Steps to Reproduce:

  1. In .rb file, type something to trigger indentation with 'end' keyword(like class or method)

After 'end' keyword is finished, indentation happens and suddenly autocompletion changes from 'end' to 'def' or other suggestion. Then, pressing enter makes 'endef', if you want to leave 'end' you need to press esc, which isn't too ergonomic.
When cursor is on proper indentation though, 'end' autocomplete seem to work just fine
Other keywords like 'else', 'rescue' behave properly

This bug didn't occur in vscode 1.13.1.
Related issue: #2272

editor-autoindent suggest verified

Most helpful comment

@jrieken I have reproduced this on an out-of-the-box installation of the latest VS Code Insiders (Version 1.21.0-insider)

1) Create a new file with a .rb extension
2) Type the word 'enabled' at the top of the file (to give autosuggestion a word to suggest from the file)
3) Begin typing out your function definition:

def foo
    bar

4) Hit enter after bar, and your cursor should be on the same indentation level as bar
5) Begin typing end. Notice that as soon as you type d the word end should unindent to the left.
6) Autosuggest will now offer enabled, and hitting enter at this point replaces end with enabled.

And now your favorite, a gif

All 19 comments

@iccub did you run into this issue still if you run without any extension? code-insiders --disable-extensions

Sorry for late reply, I'm in eu timezone

It's the same without extensions too, I reinstalled clean version to be sure

I have the same issue in Version 1.15.1 (1.15.1) as well.
end automatically becomes endef and its really dragging me down 馃槩

very annoying little issue. still going on.

Still going on for 1.18.1. Any quick fix?

Would also love to see a fix for this.

Someone: Please provide a code sample and steps that reproduce this

dec-11-2017 09-54-25

endef_vscode
Pressing ENTER after end adds endef instead of new line.

not for me...

I am working on a rails project, is that behavior probably coming from that context?

How would I be able to tell from an animated gif?

just providing more info. My understanding is that autocompletion adds suggestions from keywords coming from the file you are working on. A possible solution could be to disable it for keywords such as end when pressing enter.

just providing more info.

To be honest, you are saying I see this too and you are attaching a similar animated gif. Yes, that's more info but doesn't help me because I still cannot reproduce this. Please follow this guide: https://github.com/Microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions#writing-good-bug-reports-and-feature-requests, esp. the section of reproducible steps and the code snippet.

Please put yourself into my shoes for a second. Folks make me follow nervous gifs and make me type that into the editor (did people forget about copy&paste?!?).

It doesn't repo for me, folks say it reproduces so the truth is that the crucial piece of information is still missing. Unfortunately I don't have time for some exploratory investigation but I do have many other, more precise, issues to work on. So guess what happens? I work on other things.

So, please test this for once with latest insiders, then share your sample (not a gif nor an image, those are just for decoration), then write down precise steps that leave no room for interpretation which I can follow. A good validation is to test those steps on a different workspace, with different files and/or settings because I don't have your workspace (unless you can share it with me). Thanks for helping out.

I was having the same issue as the others above and I found a fix by installing "vscode-endwise" extension. Which will auto provide an end when one is needed.

I was having the same issue, and was able to fix it by installing the rcodetools gem.

@jrieken I have reproduced this on an out-of-the-box installation of the latest VS Code Insiders (Version 1.21.0-insider)

1) Create a new file with a .rb extension
2) Type the word 'enabled' at the top of the file (to give autosuggestion a word to suggest from the file)
3) Begin typing out your function definition:

def foo
    bar

4) Hit enter after bar, and your cursor should be on the same indentation level as bar
5) Begin typing end. Notice that as soon as you type d the word end should unindent to the left.
6) Autosuggest will now offer enabled, and hitting enter at this point replaces end with enabled.

And now your favorite, a gif

Autosuggest will now offer enabled, and hitting enter at this point replaces end with enabled.

So, your expectation is that outdenting cancels suggest, right? @rebornix Does the editor emit a special change event or a special cursor change reason for that?

Yep, I would expect the outdent to cancel any suggestions. This would match Sublime Text's behavior, demonstrated here:

sublime-behavior

Thanks @pmossman. I have pushed a change that cancels a suggest session when the start of the to be completed word shifts left. Fingers crossed that this doesn't break other, yet unknown, usages...

Was this page helpful?
0 / 5 - 0 ratings