int (@NotNull Caret caret) { Document document = caret.getEditor().getDocument(); int startOffset = caret.getOffset(); int endOffset = DocumentUtil.getLineEndOffset(startOffset, document); if (endOffset < document.getTextLength() && CharArrayUtil.isEmptyOrSpaces(document.getImmutableCharSequence(), startOffset, endOffset)) { endOffset++; } return endOffset; }