void (@NotNull Editor editor, @Nullable Caret caret, DataContext dataContext) { if (HighlighterUtil.hasHighlighters(editor)) { final int offset = editor.getCaretModel().getOffset(); final List<RangeHighlighter> hl = HighlighterUtil.getHighlighters(editor); int diff = Integer.MAX_VALUE; RangeHighlighter next = null; for (RangeHighlighter highlighter : hl) { if (isPrev) { if (highlighter.getStartOffset() < offset && offset - highlighter.getStartOffset() < diff) { diff = offset - highlighter.getStartOffset(); next = highlighter; } } else { if (highlighter.getStartOffset() > offset && highlighter.getStartOffset() - offset < diff) { diff = highlighter.getStartOffset() - offset; next = highlighter; } } } final int startOffset; if (next != null) { startOffset = next.getStartOffset(); } else if (wrapAround) { startOffset = hl.get(isPrev ? hl.size() - 1 : 0).getStartOffset(); } else { final String info = XPathBundle.message("hint.text.choice.first.last.xpath.match.reached.press.to.search.from.choice.bottom.top", isPrev ? 0 : 1, isPrev ? KeymapUtil.getShortcutText(IdeActions.ACTION_FIND_PREVIOUS) : KeymapUtil.getShortcutText(IdeActions.ACTION_FIND_NEXT), isPrev ? 0 : 1); //noinspection DialogTitleCapitalization showEditorHint(info, editor); wrapAround = true; return; } editor.getScrollingModel().scrollTo(editor.offsetToLogicalPosition(startOffset), ScrollType.MAKE_VISIBLE); editor.getCaretModel().moveToOffset(startOffset); wrapAround = false; return; } origHandler.execute(editor, caret, dataContext); }