Buggy code:
public void removeLineBackgroundListener ( LineBackgroundListener listener ) { } public void removeLineStyleListener ( LineStyleListener listener ) { } public void removeModifyListener ( ModifyListener modifyListener ) { } public void removePaintObjectListener ( PaintObjectListener listener ) { } public void removeSelectionListener ( SelectionListener listener ) { } public void removeVerifyListener ( VerifyListener verifyListener ) { } public void removeVerifyKeyListener ( VerifyKeyListener listener ) { } public void removeWordMovementListener ( MovementListener listener ) { } public void replaceStyleRanges ( int start , int length , StyleRange [ ] ranges ) { } public void replaceTextRange ( int start , int length , String text ) { } void reset ( ) { } void resetCache ( int firstLine , int count ) { } void resetSelection ( ) { } public void scroll ( int destX , int destY , int x , int y , int width , int height , boolean all ) { } boolean scrollHorizontal ( int pixels , boolean adjustScrollBar ) { } boolean scrollVertical ( int pixels , boolean adjustScrollBar ) { } void scrollText ( int srcY , int destY ) { } public void selectAll ( ) { } void sendKeyEvent ( Event event ) { } StyledTextEvent sendLineEvent ( int eventType , int lineOffset , String line ) { } void sendModifyEvent ( Event event ) { } void sendSelectionEvent ( ) { } int sendWordBoundaryEvent ( int eventType , int movement , int offset , int newOffset , String lineText , int lineOffset ) { } public void setAlignment ( int alignment ) { } public void setBackground ( Color color ) { } public void setCaret ( Caret caret ) { } public void setBidiColoring ( boolean mode ) { } void setCaretLocation ( ) { } void setCaretLocation ( Point location , int direction ) { } public void setCaretOffset ( int offset ) { } void setClipboardContent ( int start , int length , int clipboardType ) throws SWTError { } public void setContent ( StyledTextContent newContent ) { } public void setCursor ( Cursor cursor ) { } public void setDoubleClickEnabled ( boolean enable ) { } public void setDragDetect ( boolean dragDetect ) { } public void setEditable ( boolean editable ) { } public void setFont ( Font font ) { } public void setForeground ( Color color ) { } public void setHorizontalIndex ( int offset ) { } public void setHorizontalPixel ( int pixel ) { } public void setIndent ( int indent ) { } public void setJustify ( boolean justify ) { } public void setKeyBinding ( int key , int action ) { } public void setLineAlignment ( int startLine , int lineCount , int alignment ) { } public void setLineBackground ( int startLine , int lineCount , Color background ) { } public void setLineBullet ( int startLine , int lineCount , Bullet bullet ) { } void setVariableLineHeight ( ) { } public void setLineIndent ( int startLine , int lineCount , int indent ) { } public void setLineJustify ( int startLine , int lineCount , boolean justify ) { } public void setLineSpacing ( int lineSpacing ) { } void setMargins ( int leftMargin , int topMargin , int rightMargin , int bottomMargin ) { } void setMouseWordSelectionAnchor ( ) { } public void setOrientation ( int orientation ) { } void setScrollBars ( boolean vertical ) { } public void setSelection ( int start ) { } public void setSelection ( Point point ) { } public void setSelectionBackground ( Color color ) { } public void setSelectionForeground ( Color color ) { } public void setSelection ( int start , int end ) { } void setSelection ( int start , int length , boolean sendEvent ) { } public void setSelectionRange ( int start , int length ) { } public void setStyleRange ( StyleRange range ) { } public void setStyleRanges ( int start , int length , int [ ] ranges , StyleRange [ ] styles ) { } public void setStyleRanges ( int [ ] ranges , StyleRange [ ] styles ) { } void setStyleRanges ( int start , int length , int [ ] ranges , StyleRange [ ] styles , boolean reset ) { } public void setStyleRanges ( StyleRange [ ] ranges ) { } public void setTabs ( int tabs ) { } public void setText ( String text ) { } public void setTextLimit ( int limit ) { } public void setTopIndex ( int topIndex ) { } public void setTopPixel ( int pixel ) { } public void setWordWrap ( boolean wrap ) { } boolean showLocation ( Rectangle rect , boolean scrollPage ) { } void showCaret ( ) { } public void showSelection ( ) { checkWidget ( ) ; boolean rightToLeft = ( caretOffset ) == ( selection . x ) ; int startOffset ; int endOffset ; if ( rightToLeft ) { startOffset = selection . y ; endOffset = selection . x ; } else { startOffset = selection . x ; endOffset = selection . y ; } Rectangle startBounds = getBoundsAtOffset ( startOffset ) ; Rectangle endBounds = getBoundsAtOffset ( endOffset ) ; int w = ( ( clientAreaWidth ) - ( leftMargin ) ) - ( rightMargin ) ; boolean selectionFits = ( rightToLeft ) ? ( ( startBounds . x ) - ( endBounds . x ) ) <= w : ( ( endBounds . x ) - ( startBounds . x ) ) <= w ; if ( selectionFits ) { if ( showLocation ( startBounds , false ) ) { endBounds = getBoundsAtOffset ( endOffset ) ; } <START_BUG> endBounds . width = 0 ; <END_BUG> showLocation ( endBounds , false ) ; } else { showLocation ( endBounds , true ) ; } } void updateSelection ( int startOffset , int replacedLength , int newLength ) { } }

Fix:
endBounds . width = ( endOffset == ( caretOffset ) ) ? getCaretWidth ( ) : 0 ;