public static TextRange @NotNull [] getIndents(@NotNull CharSequence charsSequence, int shift) {
    List<TextRange> result = new ArrayList<>();
    int whitespaceEnd = -1;
    int lastTextFound = 0;
    for(int i = charsSequence.length() - 1; i >= 0; i--){
      char charAt = charsSequence.charAt(i);
      boolean isWhitespace = Character.isWhitespace(charAt);
      if(charAt == '\n'){
        result.add(new TextRange(i, (whitespaceEnd >= 0 ? whitespaceEnd : i) + 1).shiftRight(shift));
        whitespaceEnd = -1;
      }
      else if(whitespaceEnd >= 0 ){
        if(isWhitespace){
          continue;
        }
        lastTextFound = result.size();
        whitespaceEnd = -1;
      }
      else if(isWhitespace){
        whitespaceEnd = i;
      } else {
        lastTextFound = result.size();
      }
    }
    if(whitespaceEnd > 0) result.add(new TextRange(0, whitespaceEnd + 1).shiftRight(shift));
    result = lastTextFound >= result.size() ? result : result.subList(0, lastTextFound);
    return result.toArray(TextRange.EMPTY_ARRAY);
  }
public static TextRange @NotNull [] getIndents(@NotNull CharSequence charsSequence, int shift)