Caret (@NotNull LogicalPosition logicalPosition) { int offset = logicalPositionToOffset(logicalPosition); for (Caret caret : getCaretModel().getAllCarets()) { if (offset >= caret.getSelectionStart() && offset <= caret.getSelectionEnd()) { return caret; } } return null; }