boolean (RangeHighlighter[] highlighters, Editor editor, int offset, boolean isForward, boolean secondPass) { RangeHighlighter highlighterToSelect = null; Object wasNotFound = editor.getUserData(HIGHLIGHTER_WAS_NOT_FOUND_KEY); for (RangeHighlighter highlighter : highlighters) { int start = highlighter.getStartOffset(); int end = highlighter.getEndOffset(); if (highlighter.isValid() && start < end) { if (isForward && (start > offset || start == offset && secondPass)) { if (highlighterToSelect == null || highlighterToSelect.getStartOffset() > start) highlighterToSelect = highlighter; } if (!isForward && (end < offset || end == offset && secondPass)) { if (highlighterToSelect == null || highlighterToSelect.getEndOffset() < end) highlighterToSelect = highlighter; } } } if (highlighterToSelect != null) { expandFoldRegionsIfNecessary(editor, highlighterToSelect.getStartOffset(), highlighterToSelect.getEndOffset()); editor.getSelectionModel().setSelection(highlighterToSelect.getStartOffset(), highlighterToSelect.getEndOffset()); editor.getCaretModel().moveToOffset(highlighterToSelect.getStartOffset()); ScrollType scrollType; if (secondPass) { scrollType = isForward ? ScrollType.CENTER_UP : ScrollType.CENTER_DOWN; } else { scrollType = isForward ? ScrollType.CENTER_DOWN : ScrollType.CENTER_UP; } editor.getScrollingModel().scrollToCaret(scrollType); editor.putUserData(HIGHLIGHTER_WAS_NOT_FOUND_KEY, null); EditorSearchSession.logSelectionUpdate(); return true; } if (wasNotFound == null) { editor.putUserData(HIGHLIGHTER_WAS_NOT_FOUND_KEY, Boolean.TRUE); String message = FindBundle.message("find.highlight.no.more.highlights.found"); if (isForward) { AnAction action=ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_NEXT); String shortcutsText=KeymapUtil.getFirstKeyboardShortcutText(action); if (shortcutsText.isEmpty()) { message = FindBundle.message("find.search.again.from.top.action.message", message); } else { message = FindBundle.message("find.search.again.from.top.hotkey.message", message, shortcutsText); } } else { AnAction action=ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_PREVIOUS); String shortcutsText=KeymapUtil.getFirstKeyboardShortcutText(action); if (shortcutsText.isEmpty()) { message = FindBundle.message("find.search.again.from.bottom.action.message", message); } else { message = FindBundle.message("find.search.again.from.bottom.hotkey.message", message, shortcutsText); } } JComponent component = HintUtil.createInformationLabel(message); final LightweightHint hint = new LightweightHint(component); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false); return true; } if (!secondPass) { offset = isForward ? 0 : editor.getDocument().getTextLength(); return highlightNextHighlighter(highlighters, editor, offset, isForward, true); } return false; }