mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
preselect the most relevant item when lexicographic sorting is enabled in the lookups
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
class Foo {
|
||||
int ELEMENT_A = 1;
|
||||
int ELEMENT_B = 1;
|
||||
int ELEMENT_C = 1;
|
||||
int ELEMENT_D = 1;
|
||||
int ELEMENT_E = 1;
|
||||
int ELEMENT_F = 1;
|
||||
int ELEMENT_G = 1;
|
||||
int ELEMENT_H = 1;
|
||||
int ELEMENT_I = 1;
|
||||
|
||||
|
||||
{
|
||||
El<caret>
|
||||
}
|
||||
|
||||
}
|
||||
+20
-1
@@ -8,6 +8,7 @@ import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
|
||||
@@ -170,7 +171,8 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
|
||||
public void testDeclaredMembersGoFirst() throws Exception {
|
||||
invokeCompletion(getTestName(false) + ".java");
|
||||
assertStringItems("fromThis", "overridden", "fromSuper", "equals", "getClass", "hashCode", "notify", "notifyAll", "toString", "wait", "wait", "wait");
|
||||
assertStringItems("fromThis", "overridden", "fromSuper", "equals", "getClass", "hashCode", "notify", "notifyAll", "toString", "wait",
|
||||
"wait", "wait");
|
||||
}
|
||||
|
||||
public void testLocalVarsOverMethods() {
|
||||
@@ -246,6 +248,23 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
checkPreferredItems(0, "Bar9", "Bar1", "Bar2", "Bar3", "Bar4");
|
||||
}
|
||||
|
||||
public void testPreselectMostRelevantInTheMiddleAlpha() {
|
||||
UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = true;
|
||||
|
||||
try {
|
||||
myFixture.addClass("package foo; public class Elaaaaaaaaaaaaaaaaaaaa {}");
|
||||
invokeCompletion(getTestName(false) + ".java");
|
||||
myFixture.completeBasic();
|
||||
LookupImpl lookup = getLookup();
|
||||
assertPreferredItems(lookup.getList().getSelectedIndex());
|
||||
assertEquals("Elaaaaaaaaaaaaaaaaaaaa", lookup.getItems().get(0).getLookupString());
|
||||
assertEquals("ELEMENT_A", lookup.getCurrentItem().getLookupString());
|
||||
}
|
||||
finally {
|
||||
UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void testSortSameNamedVariantsByProximity() {
|
||||
myFixture.addClass("public class Bar {}");
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
Reference in New Issue
Block a user