diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java index 3d19a55f032e..3ce6cdddb663 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java @@ -87,6 +87,7 @@ public abstract class ChooseByNameBase { private boolean myPreselectInitialText; private final Reference myContext; private boolean mySearchInAnyPlace = false; + private NameUtil.Matcher myLastMatcher; protected Component myPreviouslyFocusedComponent; @@ -873,17 +874,23 @@ public abstract class ChooseByNameBase { private int detectBestStatisticalPosition() { int best = 0; int bestPosition = 0; + int bestMatch = Integer.MIN_VALUE; final int count = myListModel.getSize(); + NameUtil.Matcher matcher = buildPatternMatcher(getNamePattern(myTextField.getText())); + final String statContext = statisticsContext(); for (int i = 0; i < count; i++) { final Object modelElement = myListModel.getElementAt(i); String text = EXTRA_ELEM.equals(modelElement) ? null : myModel.getFullName(modelElement); if (text != null) { + String shortName = myModel.getElementName(modelElement); + int match = shortName != null && matcher instanceof NameUtil.MinusculeMatcher ? ((NameUtil.MinusculeMatcher)matcher).matchingDegree(shortName) : Integer.MIN_VALUE; int stats = StatisticsManager.getInstance().getUseCount(new StatisticsInfo(statContext, text)); - if (stats > best) { + if (stats > best || stats == best && match > bestMatch) { best = stats; bestPosition = i; + bestMatch = match; } } }