Buggy code:
static class Printing implements Runnable { static final int LEFT = 0 ; static final int CENTER = 1 ; static final int RIGHT = 2 ; Printer printer ; StyledTextRenderer printerRenderer ; StyledTextPrintOptions printOptions ; Rectangle clientArea ; FontData fontData ; Font printerFont ; Hashtable resources ; int tabLength ; GC gc ; int pageWidth ; int startPage ; int endPage ; int startLine ; int endLine ; boolean singleLine ; Point selection = null ; boolean mirrored ; int lineSpacing ; int printMargin ; Printing ( StyledText styledText , Printer printer , StyledTextPrintOptions printOptions ) { } void cacheLineData ( StyledText styledText ) { } StyledTextContent copyContent ( StyledTextContent original ) { } void dispose ( ) { } void init ( ) { } void print ( ) { } void printDecoration ( int page , boolean header , TextLayout layout ) { } void printDecorationSegment ( String segment , int alignment , int page , boolean header , TextLayout layout ) { } void printLine ( int x , int y , GC gc , Color foreground , Color background , TextLayout layout , TextLayout printLayout , int index ) { } public void run ( ) { } } class RTFWriter extends StyledText . TextWriter { static final int DEFAULT_FOREGROUND = 0 ; static final int DEFAULT_BACKGROUND = 1 ; Vector colorTable ; Vector fontTable ; boolean WriteUnicode ; public RTFWriter ( int start , int length ) { } public void close ( ) { } int getColorIndex ( Color color , int defaultIndex ) { } int getFontIndex ( Font font ) { } void setUnicode ( ) { } void write ( String string , int start , int end ) { } void writeHeader ( ) { } public void writeLine ( String line , int lineOffset ) { } public void writeLineDelimiter ( String lineDelimiter ) { } void writeStyledLine ( String line , int lineOffset , int [ ] ranges , StyleRange [ ] styles , Color lineBackground , int indent , int alignment , boolean justify ) { } } class TextWriter { private StringBuffer buffer ; private int startOffset ; private int endOffset ; private boolean isClosed = false ; public TextWriter ( int start , int length ) { } public void close ( ) { } public int getCharCount ( ) { } public int getStart ( ) { } public boolean isClosed ( ) { } public String toString ( ) { } void write ( String string ) { } void write ( String string , int offset ) { } void write ( int i ) { } void write ( char i ) { } public void writeLine ( String line , int lineOffset ) { } public void writeLineDelimiter ( String lineDelimiter ) { } } public StyledText ( Composite parent , int style ) { } public void addExtendedModifyListener ( ExtendedModifyListener extendedModifyListener ) { } public void addBidiSegmentListener ( BidiSegmentListener listener ) { } public void addCaretListener ( CaretListener listener ) { } public void addLineBackgroundListener ( LineBackgroundListener listener ) { } public void addLineStyleListener ( LineStyleListener listener ) { } public void addModifyListener ( ModifyListener modifyListener ) { } public void addPaintObjectListener ( PaintObjectListener listener ) { } public void addSelectionListener ( SelectionListener listener ) { } public void addVerifyKeyListener ( VerifyKeyListener listener ) { } public void addVerifyListener ( VerifyListener verifyListener ) { } public void addWordMovementListener ( MovementListener movementListener ) { } public void append ( String string ) { } void calculateScrollBars ( ) { } void calculateTopIndex ( int delta ) { } static int checkStyle ( int style ) { } void claimBottomFreeSpace ( ) { } void claimRightFreeSpace ( ) { <START_BUG> int newHorizontalOffset = Math . max ( 0 , ( ( renderer . getWidth ( ) ) - ( ( ( clientAreaWidth ) - ( leftMargin ) ) - ( rightMargin ) ) ) ) ; <END_BUG> if ( newHorizontalOffset < ( horizontalScrollOffset ) ) { scrollHorizontal ( ( newHorizontalOffset - ( horizontalScrollOffset ) ) , true ) ; } } void clearBlockSelection ( boolean reset , boolean sendEvent ) { } void clearSelection ( boolean sendEvent ) { } public Point computeSize ( int wHint , int hHint , boolean changed ) { } public void copy ( ) { } public void copy ( int clipboardType ) { } boolean copySelection ( int type ) { } public int getAlignment ( ) { } int getAvailableHeightAbove ( int height ) { } int getAvailableHeightBellow ( int height ) { } String getModelDelimitedText ( String text ) { } boolean checkDragDetect ( Event event ) { } void createKeyBindings ( ) { } void createCaretBitmaps ( ) { } public void cut ( ) { } void doAutoScroll ( Event event ) { } void doAutoScroll ( int direction , int distance ) { } void doBackspace ( ) { } void doBlockColumn ( boolean next ) { } void doBlockWord ( boolean next ) { } void doBlockLineVertical ( boolean up ) { } void doBlockLineHorizontal ( boolean end ) { } void doBlockSelection ( boolean sendEvent ) { } void doContent ( char key ) { } void doContentEnd ( ) { } void doContentStart ( ) { } void doCursorPrevious ( ) { } void doCursorNext ( ) { } void doDelete ( ) { } void doDeleteWordNext ( ) { } void doDeleteWordPrevious ( ) { } void doLineDown ( boolean select ) { } void doLineEnd ( ) { } void doLineStart ( ) { } void doLineUp ( boolean select ) { } void doMouseLinkCursor ( ) { } void doMouseLinkCursor ( int x , int y ) { } void doMouseLocationChange ( int x , int y , boolean select ) { } void doMouseSelection ( ) { }

Fix:
int newHorizontalOffset = Math . max ( 0 , ( ( renderer . getWidth ( ) ) - ( clientAreaWidth ) ) ) ;