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?
@eseidel There are 2 ways of handling completion item insertion in IntelliJ:
Enter - it doesn't eat anything, so you'll end up with what you expect (Thing(this.firstOne[CURSOR]this.secondOne);)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.
Sure, see 'Accept a suggestion' in https://www.jetbrains.com/help/idea/auto-completing-code.html#completion_tips
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.
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.