Fixed completion list sorting so that "shouldCompleteTopLevelCallablesFromIndex" not be first when typing "st"
This commit is contained in:
+1
-1
@@ -497,7 +497,7 @@ class BasicCompletionSession(
|
||||
|
||||
override fun addWeighers(sorter: CompletionSorter): CompletionSorter {
|
||||
if (shouldCompleteParameterNameAndType()) {
|
||||
return sorter.weighBefore(DeprecatedWeigher.toString(), ParameterNameAndTypeCompletion.Weigher)
|
||||
return sorter.weighBefore("prefix", ParameterNameAndTypeCompletion.Weigher)
|
||||
}
|
||||
return sorter
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.completion.CompletionResultSet
|
||||
import com.intellij.codeInsight.completion.CompletionSorter
|
||||
import com.intellij.codeInsight.completion.CompletionUtil
|
||||
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
|
||||
import com.intellij.codeInsight.completion.impl.RealPrefixMatchingWeigher
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.patterns.PatternCondition
|
||||
import com.intellij.patterns.StandardPatterns
|
||||
@@ -244,6 +245,9 @@ abstract class CompletionSession(
|
||||
|
||||
sorter = sorter.weighBefore("middleMatching", PreferMatchingItemWeigher)
|
||||
|
||||
// we insert one more RealPrefixMatchingWeigher because one inserted in default sorter is placed in a bad position (after "stats")
|
||||
sorter = sorter.weighAfter("lift.shorter", RealPrefixMatchingWeigher())
|
||||
|
||||
sorter = sorter.weighAfter("kotlin.proximity", ByNameAlphabeticalWeigher, PreferLessParametersWeigher)
|
||||
|
||||
return sorter
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun shouldCompleteTopLevelCallablesFromIndex() = true
|
||||
|
||||
fun foo(statement: String) {
|
||||
if (st<caret>)
|
||||
}
|
||||
|
||||
// ORDER: statement
|
||||
// ORDER: shouldCompleteTopLevelCallablesFromIndex
|
||||
+6
@@ -167,6 +167,12 @@ public class BasicCompletionWeigherTestGenerated extends AbstractBasicCompletion
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Prefix.kt")
|
||||
public void testPrefix() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/weighers/basic/Prefix.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PropertiesBeforeKeywords.kt")
|
||||
public void testPropertiesBeforeKeywords() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/weighers/basic/PropertiesBeforeKeywords.kt");
|
||||
|
||||
Reference in New Issue
Block a user