Buggy code:
int descent ; int lineEndSpaceWidth ; int averageCharWidth ; int topIndex = - 1 ; TextLayout [ ] layouts ; int lineCount ; int [ ] lineWidth ; int [ ] lineHeight ; StyledTextRenderer . LineInfo [ ] lines ; int maxWidth ; int maxWidthLineIndex ; boolean idleRunning ; Bullet [ ] bullets ; int [ ] bulletsIndices ; int [ ] redrawLines ; int [ ] ranges ; int styleCount ; StyleRange [ ] styles ; StyleRange [ ] stylesSet ; int stylesSetCount = 0 ; static final int BULLET_MARGIN = 8 ; static final boolean COMPACT_STYLES = true ; static final boolean MERGE_STYLES = true ; static final int GROW = 32 ; static final int IDLE_TIME = 50 ; static final int CACHE_SIZE = 128 ; static final int BACKGROUND = 1 << 0 ; static final int ALIGNMENT = 1 << 1 ; static final int INDENT = 1 << 2 ; static final int JUSTIFY = 1 << 3 ; static final int SEGMENTS = 1 << 5 ; static class LineInfo { int flags ; Color background ; int alignment ; int indent ; boolean justify ; int [ ] segments ; public LineInfo ( ) { } public LineInfo ( StyledTextRenderer . LineInfo info ) { } } StyledTextRenderer ( Device device , StyledText styledText ) { } int addMerge ( int [ ] mergeRanges , StyleRange [ ] mergeStyles , int mergeCount , int modifyStart , int modifyEnd ) { } int addMerge ( StyleRange [ ] mergeStyles , int mergeCount , int modifyStart , int modifyEnd ) { } void calculate ( int startLine , int lineCount ) { } void calculateClientArea ( ) { } void calculateIdle ( ) { } void clearLineBackground ( int startLine , int count ) { } void clearLineStyle ( int startLine , int count ) { } void copyInto ( StyledTextRenderer renderer ) { } void dispose ( ) { } void disposeTextLayout ( TextLayout layout ) { } void drawBullet ( Bullet bullet , GC gc , int paintX , int paintY , int index , int lineAscent , int lineDescent ) { } int drawLine ( int lineIndex , int paintX , int paintY , GC gc , Color widgetBackground , Color widgetForeground ) { TextLayout layout = getTextLayout ( lineIndex ) ; String line = content . getLine ( lineIndex ) ; int lineOffset = content . getOffsetAtLine ( lineIndex ) ; int lineLength = line . length ( ) ; Point selection = styledText . getSelection ( ) ; int selectionStart = selection . x ; int selectionEnd = selection . y ; Rectangle client = styledText . getClientArea ( ) ; Color lineBackground = getLineBackground ( lineIndex , widgetBackground ) ; StyledTextEvent event = styledText . getLineBackgroundData ( lineOffset , line ) ; if ( ( event != null ) && ( ( event . lineBackground ) != null ) ) lineBackground = event . lineBackground ; boolean fullSelection = ( ( styledText . getStyle ( ) ) & ( SWT . FULL_SELECTION ) ) != 0 ; if ( ( ( ! fullSelection ) || ( selectionStart > lineOffset ) ) || ( selectionEnd <= ( lineOffset + lineLength ) ) ) { gc . setBackground ( lineBackground ) ; <START_BUG> gc . fillRectangle ( client . x , paintY , client . width , layout . getBounds ( ) . height ) ; <END_BUG> } if ( selectionStart != selectionEnd ) { int y = paintY ; gc . setBackground ( styledText . getSelectionBackground ( ) ) ; int lineCount = layout . getLineCount ( ) ; if ( fullSelection ) { int [ ] offsets = layout . getLineOffsets ( ) ; for ( int i = 0 ; i < ( lineCount - 1 ) ; i ++ ) { int lineStart = offsets [ i ] ; if ( lineStart >= ( selectionEnd - lineOffset ) ) break ; int lineEnd = offsets [ ( i + 1 ) ] ; Rectangle lineBounds = layout . getLineBounds ( i ) ; if ( ( ( selectionStart - lineOffset ) <= lineEnd ) && ( lineEnd <= ( selectionEnd - lineOffset ) ) ) { int x = ( paintX + ( lineBounds . x ) ) + ( lineBounds . width ) ; gc . fillRectangle ( x , y , ( ( client . width ) - x ) , lineBounds . height ) ; } y += ( lineBounds . height ) + ( layout . getSpacing ( ) ) ; } } if ( ( ( selectionStart - lineOffset ) <= lineLength ) && ( lineLength < ( selectionEnd - lineOffset ) ) ) { Rectangle lineBounds = layout . getLineBounds ( ( lineCount - 1 ) ) ; int x = ( paintX + ( lineBounds . x ) ) + ( lineBounds . width ) ; if ( fullSelection ) { gc . fillRectangle ( x , ( paintY + ( lineBounds . y ) ) , ( ( ( client . width ) - ( styledText . rightMargin ) ) - x ) , lineBounds . height ) ; } else { gc . fillRectangle ( x , ( paintY + ( lineBounds . y ) ) , lineEndSpaceWidth , lineBounds . height ) ; } } } gc . setForeground ( widgetForeground ) ; gc . setBackground ( lineBackground ) ; if ( ( selectionStart == selectionEnd ) || ( ( selectionEnd <= lineOffset ) && ( selectionStart > ( ( lineOffset + lineLength ) - 1 ) ) ) ) { layout . draw ( gc , paintX , paintY ) ; } else { int start = Math . max ( 0 , ( selectionStart - lineOffset ) ) ; int end = Math . min ( lineLength , ( selectionEnd - lineOffset ) ) ; Color selectionFg = styledText . getSelectionForeground ( ) ;

Fix:
styledText . drawBackground ( gc , client . x , paintY , client . width , layout . getBounds ( ) . height ) ;