int (@NotNull Document document, int lineOffset) { int result = 0; while (lineOffset + result < document.getTextLength() && Character.isWhitespace(document.getCharsSequence().charAt(lineOffset + result))) { result++; } if (result + lineOffset > document.getTextLength()) { result--; } return Math.max(result, 0); }