void (@NotNull Editor editor, @Nullable Caret c, DataContext dataContext) { Caret caret = c == null ? editor.getCaretModel().getPrimaryCaret() : c; TextRange wordSelectionRange = getSelectionRange(editor, caret); boolean notFoundPreviously = getAndResetNotFoundStatus(editor); boolean wholeWordSearch = isWholeWordSearch(editor); if (caret.hasSelection()) { Project project = editor.getProject(); String selectedText = caret.getSelectedText(); if (project == null || selectedText == null) { return; } FindManager findManager = FindManager.getInstance(project); FindModel model = getFindModel(selectedText, wholeWordSearch); findManager.setSelectNextOccurrenceWasPerformed(); findManager.setFindNextModel(model); int searchStartOffset = notFoundPreviously ? 0 : caret.getSelectionEnd(); FindResult findResult = findManager.findString(editor.getDocument().getCharsSequence(), searchStartOffset, model); if (findResult.isStringFound()) { boolean caretAdded = FindUtil.selectSearchResultInEditor(editor, findResult, caret.getOffset() - caret.getSelectionStart()); if (!caretAdded) { // this means that the found occurence is already selected if (notFoundPreviously) { setNotFoundStatus(editor); // to make sure we won't show hint anymore if there are no more occurrences } } } else { setNotFoundStatus(editor); showHint(editor); } } else { if (wordSelectionRange == null) { return; } setSelection(editor, caret, wordSelectionRange); setWholeWordSearch(editor, true); } editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); }