mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix item preselection in goto popups
This commit is contained in:
@@ -329,6 +329,16 @@ class Intf {
|
||||
assert popup.calcSelectedIndex(popupElements.toArray(), 'xfile') == 0
|
||||
}
|
||||
|
||||
public void "test prefer prefix match"() {
|
||||
def wanted = myFixture.addClass('class PsiClassImpl {}')
|
||||
def smth = myFixture.addClass('class DroolsPsiClassImpl {}')
|
||||
def popup = createPopup(new GotoClassModel2(project))
|
||||
def popupElements = calcPopupElements(popup, 'PsiCl', false)
|
||||
|
||||
assert popupElements == [wanted, ChooseByNameBase.NON_PREFIX_SEPARATOR, smth]
|
||||
assert popup.calcSelectedIndex(popupElements.toArray(), 'PsiCl') == 0
|
||||
}
|
||||
|
||||
private List<Object> getPopupElements(ChooseByNameModel model, String text, boolean checkboxState = false) {
|
||||
return calcPopupElements(createPopup(model), text, checkboxState)
|
||||
}
|
||||
|
||||
@@ -1082,9 +1082,10 @@ public abstract class ChooseByNameBase {
|
||||
Matcher matcher = buildPatternMatcher(transformPattern(trimmedText));
|
||||
final String statContext = statisticsContext();
|
||||
Comparator<Object> itemComparator = Comparator.
|
||||
comparing(e -> !trimmedText.equalsIgnoreCase(myModel.getElementName(e))).
|
||||
comparing(e -> trimmedText.equalsIgnoreCase(myModel.getElementName(e))).
|
||||
thenComparing(e -> matchingDegree(matcher, e)).
|
||||
thenComparing(e -> getUseCount(statContext, e));
|
||||
thenComparing(e -> getUseCount(statContext, e)).
|
||||
reversed();
|
||||
|
||||
int bestPosition = 0;
|
||||
for (int i = 1; i < modelElements.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user