void (@NotNull List<? extends SearchEverywhereFoundElementInfo> list) { if (mySearchProgressIndicator == null || mySearchProgressIndicator.isCanceled()) return; boolean wasEmpty = myListModel.getSize() == 0; if (myMlService != null) { myMlService.notifySearchResultsUpdated(); } mySelectionTracker.lock(); myListModel.addElements(list); mySelectionTracker.unlock(); mySelectionTracker.restoreSelection(); if (wasEmpty && myListModel.getSize() > 0) { Object prevSelection = ((SearchEverywhereManagerImpl)SearchEverywhereManager.getInstance(myProject)) .getPrevSelection(getSelectedTabID()); if (prevSelection instanceof Integer) { for (Object item : myListModel.getItems()) { if (Objects.hashCode(item) == ((Integer)prevSelection).intValue()) { myResultsList.setSelectedValue(item, true); break; } } } } // If the selected element is a spelling correction, but there are more elements in the list // preselect the second element instead. var selectedItem = myResultsList.getSelectedValue(); if (selectedItem instanceof SearchEverywhereSpellCheckResult.Correction && myListModel.getSize() > 1) { myResultsList.setSelectedIndex(1); } myExternalSearchListeners.forEach(listener -> listener.elementsAdded(list)); }