private int wrapPositionForTabbedTextWithoutOptimization(
     @NotNull Editor editor,
     @NotNull CharSequence text,
     int spaceSize,
     int startLineOffset,
     int endLineOffset,
     int targetRangeEndOffset) {
   int width = 0;
   int x = 0;
   int newX;
   int symbolWidth;
   int result = Integer.MAX_VALUE;
   boolean wrapLine = false;
   for (int i = startLineOffset; i < Math.min(endLineOffset, targetRangeEndOffset); i++) {
     char c = text.charAt(i);
     switch (c) {
       case '\t':
         newX = EditorUtil.nextTabStop(x, editor);
         int diffInPixels = newX - x;
         symbolWidth = diffInPixels / spaceSize;
         if (diffInPixels % spaceSize > 0) {
           symbolWidth++;
         }
         break;
       default:
         newX = x + EditorUtil.charWidth(c, Font.PLAIN, editor);
         symbolWidth = 1;
     }
     if (width + symbolWidth + FormatConstants.RESERVED_LINE_WRAP_WIDTH_IN_COLUMNS
             >= mySettings.RIGHT_MARGIN
         && (Math.min(endLineOffset, targetRangeEndOffset) - i)
             >= FormatConstants.RESERVED_LINE_WRAP_WIDTH_IN_COLUMNS) {
       result = i - 1;
     }
     if (width + symbolWidth >= mySettings.RIGHT_MARGIN) {
       wrapLine = true;
       break;
     }
     x = newX;
     width += symbolWidth;
   }
   return wrapLine ? result : -1;
 }