IDEA-207411 Search Everywhere: Add sorting by element priority

This commit is contained in:
Mikhail Sokolov
2019-02-21 13:03:59 +03:00
parent f5377f05b5
commit 95a5d99679
2 changed files with 3 additions and 9 deletions
@@ -1260,14 +1260,8 @@ public class SearchEverywhereUI extends BigPopupUI implements DataProvider, Quic
return isMoreElement(index) ? index : index + 1;
}
//todo binary search
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getSortWeight() > contributor.getSortWeight()) {
return i;
}
}
return listElements.size();
index = Collections.binarySearch(list, contributor, Comparator.comparingInt(SearchEverywhereContributor::getSortWeight));
return -index - 1;
}
}
@@ -26,8 +26,8 @@ public class SearchModelTest extends LightPlatformCodeInsightFixtureTestCase {
// adding to empty -----------------------------------------------------------------------
model.addElements(Arrays.asList(
new SESearcher.ElementInfo("item_3_20", 340, STUB_CONTRIBUTOR_3),
new SESearcher.ElementInfo("item_2_20", 250, STUB_CONTRIBUTOR_2),
new SESearcher.ElementInfo("item_3_20", 340, STUB_CONTRIBUTOR_3),
new SESearcher.ElementInfo("item_1_20", 160, STUB_CONTRIBUTOR_1),
new SESearcher.ElementInfo("item_3_30", 330, STUB_CONTRIBUTOR_3),
new SESearcher.ElementInfo("item_2_10", 280, STUB_CONTRIBUTOR_2),