String (@Nullable LookupElement item) { if (item != null) { String itemText = StringUtil.notNullize(LookupElementPresentation.renderElement(item).getItemText()); String prefix = myLookup.itemPattern(item); if (prefix.isEmpty()) { return itemText; } FList<TextRange> fragments = LookupCellRenderer.getMatchingFragments(prefix, itemText); if (fragments != null && !fragments.isEmpty()) { List<TextRange> list = new ArrayList<>(fragments); return itemText.substring(list.get(list.size() - 1).getEndOffset()); } } return ""; }