mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
in Go To Class preselect the item with the biggest matching degree (IDEA-69335)
This commit is contained in:
@@ -87,6 +87,7 @@ public abstract class ChooseByNameBase {
|
||||
private boolean myPreselectInitialText;
|
||||
private final Reference<PsiElement> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user