Flutter-intellij: document the difference in behavior in code completion between selecting items with tab or enter

Created on 23 Apr 2017  路  8Comments  路  Source: flutter/flutter-intellij

class Thing {
  int firstOne;
  int secondOne;
  Thing(this.secondOne);
}

Place your cursor between 'Thing(' and 'this' i.e. Thing([CURSOR]this.secondOne) Type this., press Tab and notice how you end up with:

Thing(this.firstOne.secondOne); instead of Thing(this.firstOne[CURSOR]this.secondOne);

Or maybe even better would be Thing(this.firstOne, [CURSOR]this.secondOne); since it should be able to tell what I'm doing. :)

@pq told me to start filing these cases where IntelliJ autocomplete unexpectedly eats things after my cursor.

I feel like I'm used to other auto-complete systems never affecting anything after my cursor, but maybe I'm remembering wrong?

docs

Most helpful comment

I think the resolution here is to better document that there's a difference in behavior in how you select items from the completion dialog.

All 8 comments

@eseidel There are 2 ways of handling completion item insertion in IntelliJ:

  • The first one is Enter - it doesn't eat anything, so you'll end up with what you expect (Thing(this.firstOne[CURSOR]this.secondOne);)
  • The second way is Tab - it eats the tail of the identifier to the right from the cursor. If there's a space or other non-identifier symbol after cursor then it behaves the same as Enter.

So it works as designed. I think this can be closed.

Thanks @alexander-doroshko ! Is there user documentation we can point folks to? There's been some consistent confusion on completion insert behavior.

consistent confusion on completion insert behavior

Interesting, some are expecting to always replace the tail (Phil was among them AFAIR), others (like Eric) are expecting to just insert the item. Luckily IntelliJ IDEA is powerful enough to satisfy both workflows.

Thanks for the pointer!

@mit-mit : maybe we capture this somewhere for an FAQ?

TIL "tab-complete" and "return-complete" are different things in IntelliJ. And command-shift-return-complete is a whole 'nother can-o-worms.

cc @jwren FYI

I think the resolution here is to better document that there's a difference in behavior in how you select items from the completion dialog.

Was this page helpful?
0 / 5 - 0 ratings