private static int wrapPositionForTabbedTextWithoutOptimization(@NotNull Editor editor,
                                                                  @NotNull CharSequence text,
                                                                  int spaceSize,
                                                                  int startLineOffset,
                                                                  int endLineOffset,
                                                                  int targetRangeEndOffset,
                                                                  int reservedWidthInColumns,
                                                                  int rightMargin)
  {
    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);
      if (c == '\t') {
        newX = EditorUtil.nextTabStop(x, editor);
        int diffInPixels = newX - x;
        symbolWidth = diffInPixels / spaceSize;
        if (diffInPixels % spaceSize > 0) {
          symbolWidth++;
        }
      }
      else {
        newX = x + EditorUtil.charWidth(c, Font.PLAIN, editor);
        symbolWidth = 1;
      }
      if (width + symbolWidth + reservedWidthInColumns >= rightMargin
          && (Math.min(endLineOffset, targetRangeEndOffset) - i) >= reservedWidthInColumns)
      {
        result = i - 1;
      }
      if (width + symbolWidth >= rightMargin) {
        wrapLine = true;
        break;
      }
      x = newX;
      width += symbolWidth;
    }
    return wrapLine ? result : -1;
  }
private static int wrapPositionForTabbedTextWithoutOptimization(@NotNull Editor editor,
                                                                  @NotNull CharSequence text,
                                                                  int spaceSize,
                                                                  int startLineOffset,
                                                                  int endLineOffset,
                                                                  int targetRangeEndOffset,
                                                                  int reservedWidthInColumns,
                                                                  int rightMargin)