first char is neglected in CompletionContributor

when I use my auto completion implemented via CompletionContributor I experience the strange effect that the results match my input string except the first char.
This happens only when I start typing without pressing CTRL-Space. It works fine when I first press CTRL-Space and start typing then.

Another thing I don't understand is the method fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result). Debugging shows that the PsiElement returned by parameters.getPosition() is always of one type (MyTokenTypes.REFERENCE). At the caret position also another element type is allowed (MyTokenTypes.PROPERTY), The completion popup also only appears when I implement the extends-method with the MyTokenTypes.REFERENCE pattern:

extend(CompletionType.BASIC,                 PlatformPatterns.psiElement(MyTokenTypes.REFERENCE)

When fillCompletionVariants is called why never parameters.getPosition() never contains an element of type MyTokenTypes.PROPERTY? What determines which PsiElement is created (a kind of pseudo-element with element.getText() == "I") at the caret position?

Thanks for any help,

Please sign in to leave a comment.