boolean (LookupElement item) { Editor editor = myLookup.getEditor(); int start = editor.getCaretModel().getOffset() - myLookup.itemPattern(item).length(); Document document = editor.getDocument(); return start >= 0 && StringUtil.startsWith(document.getImmutableCharSequence().subSequence(start, document.getTextLength()), item.getLookupString()); }