void (final Editor editor, int caretOffset, String stringToFind, FindModel model, Project project) { String message = FindBundle.message("find.search.string.not.found.message", stringToFind); short position = HintManager.UNDER; if (model.isGlobal()) { final FindModel newModel = model.clone(); FindManager findManager = FindManager.getInstance(project); Document document = editor.getDocument(); FindResult result = findManager.findString(document.getCharsSequence(), newModel.isForward() ? 0 : document.getTextLength(), model, getVirtualFile(editor)); if (!result.isStringFound()) { result = null; } FindModel modelForNextSearch = findManager.getFindNextModel(editor); if (modelForNextSearch == null) { modelForNextSearch = findManager.getFindInFileModel(); } if (result != null) { if (newModel.isForward()) { AnAction action = ActionManager.getInstance().getAction( modelForNextSearch.isForward() ? IdeActions.ACTION_FIND_NEXT : IdeActions.ACTION_FIND_PREVIOUS); String shortcutsText = KeymapUtil.getFirstKeyboardShortcutText(action); if (!shortcutsText.isEmpty()) { message = FindBundle.message("find.search.again.from.top.hotkey.message", message, shortcutsText); } else { message = FindBundle.message("find.search.again.from.top.action.message", message); } editor.putUserData(KEY, Direction.DOWN); } else { AnAction action = ActionManager.getInstance().getAction( modelForNextSearch.isForward() ? IdeActions.ACTION_FIND_PREVIOUS : IdeActions.ACTION_FIND_NEXT); String shortcutsText = KeymapUtil.getFirstKeyboardShortcutText(action); if (!shortcutsText.isEmpty()) { message = FindBundle.message("find.search.again.from.bottom.hotkey.message", message, shortcutsText); } else { message = FindBundle.message("find.search.again.from.bottom.action.message", message); } editor.putUserData(KEY, Direction.UP); position = HintManager.ABOVE; } } CaretListener listener = new CaretListener() { @Override public void caretPositionChanged(@NotNull CaretEvent e) { editor.putUserData(KEY, null); editor.getCaretModel().removeCaretListener(this); } }; editor.getCaretModel().addCaretListener(listener); } JComponent component = HintUtil.createInformationLabel(JDOMUtil.escapeText(message, false, false)); LightweightHint hint = new LightweightHint(component); LogicalPosition caretPosition = editor.offsetToLogicalPosition(caretOffset); @PositionFlags short finalPosition = position; editor.getScrollingModel().scrollTo(caretPosition, ScrollType.MAKE_VISIBLE); editor.getScrollingModel().runActionOnScrollingFinished(() -> { Point hintPoint = HintManagerImpl.getHintPosition(hint, editor, caretPosition, finalPosition); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, hintPoint, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false, finalPosition); }); }