Buggy code:
abstract class StyledTextRenderer { private Device device ; protected Font regularFont ; protected Font boldFont ; protected Font italicFont ; protected Font boldItalicFont ; private int tabWidth ; private int ascent ; private int descent ; private int lineEndSpaceWidth ; StyledTextRenderer ( Device device , Font regularFont ) { } void calculateLineHeight ( ) { } void dispose ( ) { } protected abstract void disposeGC ( GC gc ) { } void drawLine ( String line , int lineIndex , int paintY , GC gc , Color widgetBackground , Color widgetForeground , boolean clearBackground ) { int lineOffset = getContent ( ) . getOffsetAtLine ( lineIndex ) ; int lineLength = line . length ( ) ; Point selection = getSelection ( ) ; int selectionStart = selection . x ; int selectionEnd = selection . y ; int leftMargin = getLeftMargin ( ) ; Color lineBackground = null ; TextLayout layout = getTextLayout ( line , lineOffset ) ; Rectangle client = getClientArea ( ) ; StyledTextEvent event = getLineBackgroundData ( lineOffset , line ) ; if ( event != null ) { lineBackground = event . lineBackground ; } if ( lineBackground == null ) { lineBackground = widgetBackground ; } <START_BUG> if ( clearBackground && ( ( ( ( isFullLineSelection ( ) ) == false ) || ( selectionStart > lineOffset ) ) || ( selectionEnd <= ( lineOffset + lineLength ) ) ) ) { <END_BUG> gc . setBackground ( lineBackground ) ; gc . setForeground ( lineBackground ) ; gc . fillRectangle ( ( ( client . x ) + leftMargin ) , paintY , client . width , ( ( ascent ) + ( descent ) ) ) ; } int paintX = ( ( client . x ) + leftMargin ) - ( getHorizontalPixel ( ) ) ; if ( selectionStart != selectionEnd ) { Rectangle rect = layout . getLineBounds ( 0 ) ; drawLineBreakSelection ( line , lineOffset , ( ( paintX + ( rect . x ) ) + ( rect . width ) ) , paintY , gc ) ; } 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 ) ) ; layout . draw ( gc , paintX , paintY , start , ( end - 1 ) , getSelectionForeground ( ) , getSelectionBackground ( ) ) ; } disposeTextLayout ( layout ) ; } protected abstract void drawLineBreakSelection ( String line , int lineOffset , int paintX , int paintY , GC gc ) { } protected abstract Rectangle getClientArea ( ) { } protected abstract StyledTextContent getContent ( ) { } Device getDevice ( ) { } int getBaseline ( ) { } protected abstract int [ ] getBidiSegments ( int lineOffset , String lineText ) { } Font getFont ( int style ) { } FontData [ ] getFontData ( int style ) { } protected abstract GC getGC ( ) { } protected abstract int getHorizontalPixel ( ) { } protected int getLeftMargin ( ) { } int getLineEndSpaceWidth ( ) { } protected abstract StyledTextEvent getLineBackgroundData ( int lineOffset , String line ) { } int getLineHeight ( ) { } StyledTextEvent getLineStyleData ( StyledTextEvent event , int lineOffset , String line ) { } protected abstract StyledTextEvent getLineStyleData ( int lineOffset , String line ) { } protected abstract int getOrientation ( ) { } protected int getRightMargin ( ) { } protected abstract Color getSelectionForeground ( ) { } protected abstract Color getSelectionBackground ( ) { } protected abstract Point getSelection ( ) { } StyleRange [ ] getVisualLineStyleData ( StyleRange [ ] logicalStyles , int lineOffset , int lineLength ) { } protected abstract boolean getWordWrap ( ) { } protected abstract boolean isFullLineSelection ( ) { } void setTabLength ( int tabLength ) { } TextLayout getTextLayout ( String line , int lineOffset ) { } TextLayout createTextLayout ( int lineOffset ) { } void disposeTextLayout ( TextLayout layout ) { } }

Fix:
if ( clearBackground && ( ( ( ! ( isFullLineSelection ( ) ) ) || ( selectionStart > lineOffset ) ) || ( selectionEnd <= ( lineOffset + lineLength ) ) ) ) {