diff --git a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java index 5ec7c857db0d..fe26f8dd12d8 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java @@ -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; } } diff --git a/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/SearchModelTest.java b/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/SearchModelTest.java index bddfc6019113..053f35c2c2a0 100644 --- a/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/SearchModelTest.java +++ b/platform/lang-impl/testSources/com/intellij/ide/actions/searcheverywhere/SearchModelTest.java @@ -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),