@NotNull private static TextRange processTabs(@NotNull Helper helper,@NotNull TextRange range,int tabWidth){
  CharSequence indent=helper.getCurrentLineIndent();
  int start=Math.max(0,range.getStartOffset() - helper.getCurrentLineStartOffset());
  int end=Math.min(indent.length(),range.getEndOffset() - helper.getCurrentLineStartOffset());
  int replacementsNumber=0;
  int consecutiveSpaces=0;
  for (int i=start; i < end; i++) {
    char c=indent.charAt(i);
    if (c == ' ') {
      ++consecutiveSpaces;
    }
 else {
      int tabsNumber=consecutiveSpaces / tabWidth;
      if (tabsNumber > 0) {
        helper.replace(i - consecutiveSpaces,i - consecutiveSpaces + tabsNumber * tabWidth,StringUtil.repeat("\t",tabsNumber));
        replacementsNumber++;
        consecutiveSpaces=0;
      }
      if (c != '\t') {
        break;
      }
    }
  }
  int tabsNumber=consecutiveSpaces / tabWidth;
  if (tabsNumber > 0) {
    helper.replace(end - consecutiveSpaces,end - consecutiveSpaces + tabsNumber * tabWidth,StringUtil.repeat("\t",tabsNumber));
  }
  if (replacementsNumber > 0) {
    return TextRange.create(range.getStartOffset(),range.getEndOffset() - replacementsNumber * (tabWidth - 1));
  }
 else {
    return range;
  }
}

@ NotNull private static TextRange processTabs ( @ NotNull Helper helper , @ NotNull TextRange range , int tabWidth ) { CharSequence indent = helper . getCurrentLineIndent ( ) ; int start = Math . max ( 0 , range . getStartOffset ( ) - helper . getCurrentLineStartOffset ( ) ) ; int end = Math . min ( indent . length ( ) , range . getEndOffset ( ) - helper . getCurrentLineStartOffset ( ) ) ; int replacementsNumber = 0 ; int consecutiveSpaces = 0 ; for ( int i = start ; i < end ; i ++ ) { char c = indent . charAt ( i ) ; if ( c == ' ' ) { ++ consecutiveSpaces ; } else { int tabsNumber = consecutiveSpaces / tabWidth ; if ( tabsNumber > 0 ) { helper . replace ( i - consecutiveSpaces , i - consecutiveSpaces + tabsNumber * tabWidth , StringUtil . repeat ( "\t" , tabsNumber ) ) ; replacementsNumber ++ ; consecutiveSpaces = 0 ; } if ( c != '\t' ) { break ; } } } int tabsNumber = consecutiveSpaces / tabWidth ; if ( tabsNumber > 0 ) { helper . replace ( end - consecutiveSpaces , end - consecutiveSpaces + tabsNumber * tabWidth , StringUtil . repeat ( "\t" , tabsNumber ) ) ; } if ( replacementsNumber > 0 ) { return TextRange . create ( range . getStartOffset ( ) , range . getEndOffset ( ) - replacementsNumber * ( tabWidth - 1 ) ) ; } else { return range ; } }
converts white spaces to tabulations at the target line ' s indent space .
