private int getTextPreferredWidth() {
    if (!myWidthIsValid) {
      assert !myDocument.isInBulkUpdate();
      assert !myEditor.getInlayModel().isInBatchMode();
      boolean needFullScan = true;
      if (myStartInvalidLine <= myEndInvalidLine && (myEndInvalidLine - myStartInvalidLine) < SPECIFIC_LINES_RECALC_THRESHOLD ) {
        IntPair pair = calculateTextPreferredWidth(myStartInvalidLine, myEndInvalidLine);
        needFullScan = pair.first < myWidthInPixels &&
                       myStartInvalidLine <= myWidthDefiningLineNumber && myWidthDefiningLineNumber <= myEndInvalidLine;
        if (pair.first >= myWidthInPixels) {
          myWidthInPixels = pair.first;
          myWidthDefiningLineNumber = pair.second;
        }
      }
      if (needFullScan) {
        IntPair pair = calculateTextPreferredWidth(0, Integer.MAX_VALUE);
        myWidthInPixels = pair.first;
        myWidthDefiningLineNumber = pair.second;
      }
      myWidthIsValid = true;
      myStartInvalidLine = Integer.MAX_VALUE;
      myEndInvalidLine = 0;
    }
    validateMaxLineWithExtension();
    return Math.max(myWidthInPixels, myMaxLineWithExtensionWidth);
  }
private int getTextPreferredWidth()