void () { myEditor.getDocument().addDocumentListener(new DocumentListener() { @Override public void documentChanged(@NotNull DocumentEvent e) { if (canHide()) { hideLookup(false); } } }, this); final EditorMouseListener mouseListener = new EditorMouseListener() { @Override public void mouseClicked(@NotNull EditorMouseEvent e){ e.consume(); hideLookup(false); } }; myEditor.getCaretModel().addCaretListener(new CaretListener() { @Override public void caretPositionChanged(@NotNull CaretEvent e) { if (canHide()) { hideLookup(false); } } }, this); myEditor.getSelectionModel().addSelectionListener(new SelectionListener() { @Override public void selectionChanged(@NotNull final SelectionEvent e) { if (canHide()) { hideLookup(false); } } }, this); myEditor.addEditorMouseListener(mouseListener, this); JComponent editorComponent = myEditor.getContentComponent(); if (editorComponent.isShowing()) { Disposer.register(this, UiNotifyConnector.installOn(editorComponent, new Activatable() { @Override public void hideNotify() { hideLookup(false); } })); Window window = ComponentUtil.getWindow(editorComponent); if (window != null) { ComponentListener windowListener = new ComponentAdapter() { @Override public void componentMoved(ComponentEvent event) { hideLookup(false); } }; window.addComponentListener(windowListener); Disposer.register(this, () -> window.removeComponentListener(windowListener)); } } myList.addListSelectionListener(new ListSelectionListener() { private LookupElement oldItem = null; @Override public void valueChanged(@NotNull ListSelectionEvent e){ if (!myUpdating) { final LookupElement item = getCurrentItem(); fireCurrentItemChanged(oldItem, item); oldItem = item; } } }); new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent e, int clickCount) { setLookupFocusDegree(LookupFocusDegree.FOCUSED); markSelectionTouched(); if (clickCount == 2){ CommandProcessor.getInstance().executeCommand(myProject, () -> finishLookup(NORMAL_SELECT_CHAR), "", null, myEditor.getDocument()); } return true; } }.installOn(myList); addPrefixChangeListener(new PrefixChangeListener() { @Override public void afterAppend(char c) { myCellRenderer.scheduleUpdateLookupWidthFromVisibleItems(); } }, this); }