skip to Main Content

I don’t think this is just Scala, or the Metals plugin. I remember this happening with Python, too, but my current situation is with Scala.

I really like using autofill and suggestions; it’s my favorite part of any IDE, including VS Code.

VS Code autofill works great, it’s just really frustrating where it puts the cursor after autofilling. And I feel like I must be doing something wrong, since I couldn’t find any search of others having this problem.

Example:

Below I am writing println, just as a dummy, but it happens with any autofill. I type enough so that I can see the autocomplete options appear.

Autofill, beforehand

Then I hit to autocomplete on the highlighted option, and it fills with the cursor after the closing parenthesis:

Autofill, afterwards

But, of course, when I autofill, I want the cursor to be inside the parentheses, not after them.

What can I do to get autocomplete to be more friendly in VS Code?

2

Answers


  1. Chosen as BEST ANSWER

    Argh!! I eventually figured out what was happening, and why it seemed so inconsistent:

    If I choose an autofilled function that requires no arguments, then it will autofill and place the cursor at the end of the parentheses. If I choose one that does require arguments, then it will go inside the parentheses.

    That makes sense, except that there are several functions which can be used without arguments, but rarely are, and VS Code will always put the no-argument case as the top choice. So, if you see the top one and are "happy" with it and choose it, the cursor will jump to the end.

    println with no arguments and with one argument

    As you can see above, there is a no argument println() which is the top of the autofill list. Not ideal, but at least now I understand what was going on. Not sure of a fast way to fix it, since again, this is something that I will be typing a bunch. Probably just avoiding autofill will be fastest. :(


  2. It took me few minutes to figure out that choosing version of method with argument will put the cursor inside the parenthesis instead of outside, which happens for choosing parameterless version.

    What you can do to improve it is to go to your VS Code settings.json file and check if there is a setting called "editor.suggestSelection": "first". Change the default value to recentlyUsed or even recentlyUsedByPrefix. With this you can "teach" VS Code to suggest top used by you suggestions, which I believe at the end are the ones you want to have recommended. More about suggestion selection.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search