void (int offset) { Runnable runnable = () -> myEditor.getCaretModel().moveToOffset(restoreCaretOffset(offset)); LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(myEditor); if (lookup != null && lookup.getLookupStart() <= (restoreCaretOffset(offset))) { lookup.setLookupFocusDegree(LookupFocusDegree.UNFOCUSED); lookup.performGuardedChange(runnable); } else { runnable.run(); } }