boolean (@NotNull Editor editor, @NotNull FindResult result, int caretShiftFromSelectionStart) { if (!editor.getCaretModel().supportsMultipleCarets() || EditorUtil.checkMaxCarets(editor)) { return false; } int caretOffset = getCaretPosition(result, caretShiftFromSelectionStart); LogicalPosition caretPosition = editor.offsetToLogicalPosition(caretOffset); if (caretShiftFromSelectionStart == 0) caretPosition = caretPosition.leanForward(true); EditorActionUtil.makePositionVisible(editor, caretOffset); Caret newCaret = editor.getCaretModel().addCaret(caretPosition, true); if (newCaret == null) { return false; } else { int selectionStartOffset = result.getStartOffset(); int selectionEndOffset = result.getEndOffset(); EditorActionUtil.makePositionVisible(editor, selectionStartOffset); EditorActionUtil.makePositionVisible(editor, selectionEndOffset); newCaret.setSelection(selectionStartOffset, selectionEndOffset); EditorSearchSession.logSelectionUpdate(); return true; } }