mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-151515 (Goto Action sorts incorrectly)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,6 +43,20 @@ class GotoActionTest extends LightCodeInsightFixtureTestCase {
|
||||
matchedValue(byDesc, pattern, GotoActionModel.MatchMode.DESCRIPTION)].sort()
|
||||
assert [byName, byDesc] == items.collect { it.valueText }
|
||||
}
|
||||
|
||||
public void "test sort by degree"() {
|
||||
def pattern = 'c'
|
||||
def copy = 'Copy'
|
||||
def aardvark = 'Aardvarck'
|
||||
def boom = 'Boom'
|
||||
def deaf = 'deaf'
|
||||
def eclaire = 'eclaire'
|
||||
def cut = 'Cut'
|
||||
def c = 'c'
|
||||
def items = [matchedValue(boom, pattern), matchedValue(aardvark, pattern), matchedValue(copy, pattern),
|
||||
matchedValue(eclaire, pattern), matchedValue(deaf, pattern), matchedValue(cut, pattern), matchedValue(c, pattern)].sort()
|
||||
assert [c, copy, cut, aardvark, eclaire, boom, deaf] == items.collect { it.valueText }
|
||||
}
|
||||
|
||||
static def matchedValue(String fork, String pattern) {
|
||||
matchedValue(fork, pattern, GotoActionModel.MatchMode.NAME)
|
||||
|
||||
@@ -191,6 +191,9 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull MatchedValue o) {
|
||||
int diff = o.getMatchingDegree() - getMatchingDegree();
|
||||
if (diff != 0) return diff;
|
||||
|
||||
boolean edt = ApplicationManager.getApplication().isDispatchThread();
|
||||
|
||||
if (value instanceof ActionWrapper && o.value instanceof ActionWrapper) {
|
||||
@@ -219,9 +222,6 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
|
||||
if (value instanceof OptionDescription && !(o.value instanceof OptionDescription)) return 1;
|
||||
if (o.value instanceof OptionDescription && !(value instanceof OptionDescription)) return -1;
|
||||
|
||||
int diff = o.getMatchingDegree() - getMatchingDegree();
|
||||
if (diff != 0) return diff;
|
||||
|
||||
diff = StringUtil.notNullize(getValueText()).length() - StringUtil.notNullize(o.getValueText()).length();
|
||||
if (diff != 0) return diff;
|
||||
|
||||
@@ -622,10 +622,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
|
||||
Presentation oPresentation = o.getAction().getTemplatePresentation();
|
||||
String myText = myPresentation.getText();
|
||||
String oText = oPresentation.getText();
|
||||
int byText = StringUtil.compare(StringUtil.trimEnd(myText, "..."), StringUtil.trimEnd(oText, "..."), true);
|
||||
if (byText != 0) return byText;
|
||||
int byTextLength = StringUtil.notNullize(myText).length() - StringUtil.notNullize(oText).length();
|
||||
if (byTextLength != 0) return byTextLength;
|
||||
int byText = StringUtil.compare(myText, oText, true);
|
||||
if (byText != 0) return byText;
|
||||
int byGroup = Comparing.compare(myGroupName, o.getGroupName());
|
||||
if (byGroup != 0) return byGroup;
|
||||
int byDesc = StringUtil.compare(myPresentation.getDescription(), oPresentation.getDescription(), true);
|
||||
|
||||
Reference in New Issue
Block a user