Disable default autocomplete sorting with plugin
Answered
Hi!
I'm currently working on a custom language plugin.
I want autocomplete lookup to show elements in a certain order, but when I trigger autocomplete in a debug instance of Idea my order given by lookup elements priorities is violated by some additional sorting. I tried to add order="first" to <completion.contributor>, but it didn’t work. How do I force elements to be sorted only by given priorities?
I add elements to CompletionResultSet like this:
val frequency = CompletionSource.getFrequency(word)
val element = PrioritizedLookupElement.withPriority(
LookupElementBuilder.create(word).withTypeText(frequency.toString()),
frequency!!.toDouble()
)
result.withPrefixMatcher(prefix).addElement(element)
Please sign in to leave a comment.
Please see "How are lookup elements sorted?" in com.intellij.codeInsight.completion.CompletionContributor javadoc.
Thank you! I implemented custom CompletionWeigher and it worked.