private static int getIndentLengthAtLineStart(@NotNull Document document, int lineOffset) {
    CharSequence content = document.getImmutableCharSequence();
    int result = 0;
    while (lineOffset + result < content.length()) {
      char ch = content.charAt(lineOffset + result);
      if (!Character.isWhitespace(ch) || ch == '\n' || ch == '\r') {
        break;
      }
      result++;
    }
    return result;
  }
private static int getIndentLengthAtLineStart(@NotNull Document document, int lineOffset)