List<LookupElement> (List<? extends LookupElement> items) { Editor editor = myProcess.getParameters().getEditor(); if (editor instanceof EditorWindow) { editor = ((EditorWindow)editor).getDelegate(); } String selectedText = editor.getSelectionModel().getSelectedText(); List<LookupElement> exactMatches = new SmartList<>(); for (LookupElement item : items) { if (isPrefixItem(item, true) || item.getLookupString().equals(selectedText)) { exactMatches.add(item); } } return exactMatches; }