Buggy code:
public int getBaseline ( ) { } public int getBaseline ( int offset ) { } public boolean getBidiColoring ( ) { } int getBottomIndex ( ) { } Rectangle getBoundsAtOffset ( int offset ) { } public int getCaretOffset ( ) { } int getCaretWidth ( ) { } Object getClipboardContent ( int clipboardType ) { } int getClusterNext ( int offset , int lineIndex ) { } int getClusterPrevious ( int offset , int lineIndex ) { } public StyledTextContent getContent ( ) { } public boolean getDragDetect ( ) { } public boolean getDoubleClickEnabled ( ) { } public boolean getEditable ( ) { } public Color getForeground ( ) { } int getHorizontalIncrement ( ) { } public int getHorizontalIndex ( ) { } public int getHorizontalPixel ( ) { } public int getIndent ( ) { } public boolean getJustify ( ) { } public int getKeyBinding ( int key ) { } public int getCharCount ( ) { } public int getLineAlignment ( int index ) { } public int getLineAtOffset ( int offset ) { } public Color getLineBackground ( int index ) { } public Bullet getLineBullet ( int index ) { } StyledTextEvent getLineBackgroundData ( int lineOffset , String line ) { } public int getLineCount ( ) { } int getLineCountWhole ( ) { } public String getLineDelimiter ( ) { } public int getLineHeight ( ) { } public int getLineHeight ( int offset ) { } public int getLineIndent ( int index ) { } public boolean getLineJustify ( int index ) { } public int getLineSpacing ( ) { } StyledTextEvent getLineStyleData ( int lineOffset , String line ) { } public int getLinePixel ( int lineIndex ) { } public int getLineIndex ( int y ) { } public Point getLocationAtOffset ( int offset ) { } public int getOffsetAtLine ( int lineIndex ) { } public int getOffsetAtLocation ( Point point ) { } int getOffsetAtPoint ( int x , int y ) { } int getOffsetAtPoint ( int x , int y , int lineIndex ) { } int getOffsetAtPoint ( int x , int y , int [ ] trailing ) { } public int getOrientation ( ) { } int getPartialBottomIndex ( ) { } int getPartialTopIndex ( ) { } String getPlatformDelimitedText ( StyledText . TextWriter writer ) { } public int [ ] getRanges ( ) { } public int [ ] getRanges ( int start , int length ) { } public Point getSelection ( ) { } public Point getSelectionRange ( ) { } public Color getSelectionBackground ( ) { } public int getSelectionCount ( ) { } public Color getSelectionForeground ( ) { } public String getSelectionText ( ) { } public int getStyle ( ) { } int [ ] getBidiSegments ( int lineOffset , String line ) { } int [ ] getBidiSegmentsCompatibility ( String line , int lineOffset ) { } public StyleRange getStyleRangeAtOffset ( int offset ) { } public StyleRange [ ] getStyleRanges ( ) { } public StyleRange [ ] getStyleRanges ( boolean includeRanges ) { } public StyleRange [ ] getStyleRanges ( int start , int length ) { } public StyleRange [ ] getStyleRanges ( int start , int length , boolean includeRanges ) { } public int getTabs ( ) { } public String getText ( ) { } public String getText ( int start , int end ) { } public Rectangle getTextBounds ( int start , int end ) { } public String getTextRange ( int start , int length ) { } public int getTextLimit ( ) { } public int getTopIndex ( ) { } public int getTopPixel ( ) { } int getVerticalIncrement ( ) { } int getVerticalScrollOffset ( ) { } int getVisualLineIndex ( TextLayout layout , int offsetInLine ) { } int getCaretDirection ( ) { } int getCaretLine ( ) { } int getWrapWidth ( ) { if ( ( wordWrap ) && ( ! ( isSingleLine ( ) ) ) ) { <START_BUG> int width = ( ( clientAreaWidth ) - ( leftMargin ) ) - ( rightMargin ) ; <END_BUG> return width > 0 ? width : 1 ; } return - 1 ; } int getWordNext ( int offset , int movement ) { } int getWordPrevious ( int offset , int movement ) { } public boolean getWordWrap ( ) { } Point getPointAtOffset ( int offset ) { } public void insert ( String string ) { } void installDefaultContent ( ) { } void installListeners ( ) { } void internalRedrawRange ( int start , int length ) { } void handleCompositionHittest ( Event event ) { } void handleCompositionChanged ( Event event ) { } void handleImeComposition ( Event event ) { } void handleDispose ( Event event ) { } void handleHorizontalScroll ( Event event ) { } void handleKey ( Event event ) { } void handleKeyDown ( Event event ) { } void handleKeyUp ( Event event ) { } void handleMouseDown ( Event event ) { } void handleMouseMove ( Event event ) { } void handleMouseUp ( Event event ) { } void handlePaint ( Event event ) { } void handleResize ( Event event ) { } void handleTextChanged ( TextChangedEvent event ) { } void handleTextChanging ( TextChangingEvent event ) { } void handleTextSet ( TextChangedEvent event ) { } void handleTraverse ( Event event ) { } void handleVerticalScroll ( Event event ) { } void initializeAccessible ( ) { } Label getAssociatedLabel ( ) { } String stripMnemonic ( String string ) { } char _findMnemonic ( String string ) { } public void invokeAction ( int action ) { } boolean isBidi ( ) { } boolean isBidiCaret ( ) { } boolean isFixedLineHeight ( ) { } boolean isLineDelimiter ( int offset ) { }

Fix:
int width = ( ( ( clientAreaWidth ) - ( leftMargin ) ) - ( rightMargin ) ) - ( getCaretWidth ( ) ) ;