boolean (boolean onExplicitAction, boolean reused) { if (!ApplicationManager.getApplication().isUnitTestMode()) { ThreadingAssertions.assertEventDispatchThread(); } checkValid(); CollectionListModelWithBatchUpdate<LookupElement> listModel = getListModel(); Pair<List<LookupElement>, Integer> pair = myPresentableArranger.arrangeItems(this, onExplicitAction || reused); List<LookupElement> items = pair.first; Integer toSelect = pair.second; if (toSelect == null || toSelect < 0 || items.size() > 0 && toSelect >= items.size()) { LOG.error("Arranger " + myPresentableArranger + " returned invalid selection index=" + toSelect + "; items=" + items); toSelect = 0; } if (!myPresentation.getMostRelevantOnTop()) { items = ContainerUtil.reverse(items); toSelect = Math.max(0, items.size() - toSelect - 1); } if (!myFirstElementAdded && !items.isEmpty()) { myFirstElementAdded = true; myListeners.forEach(LookupListener::firstElementShown); } myOffsets.checkMinPrefixLengthChanges(items, this); List<LookupElement> oldModel = listModel.toList(); List<LookupElement> finalItems = items; listModel.performBatchUpdate(model -> { synchronized (myUiLock) { model.removeAll(); if (!finalItems.isEmpty()) { Long currentTimeMillis = System.currentTimeMillis(); finalItems.forEach(item -> item.putUserDataIfAbsent(LOOKUP_ELEMENT_SHOW_TIMESTAMP_MILLIS, currentTimeMillis)); model.add(finalItems); addDummyItems(myDummyItemCount.get()); } else { addEmptyItem(model); } } }); updateListHeight(listModel); myList.setSelectedIndex(toSelect); if (ScreenReader.isActive()) { AccessibleContext context = myList.getAccessibleContext(); Accessible child = context.getAccessibleChild(myList.getSelectedIndex()); context.firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, null, child); } return !ContainerUtil.equalsIdentity(oldModel, items); }