Buggy code:
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 ) { int line = getLineIndex ( y ) ; updateCaretDirection = true ; if ( blockSelection ) { x = Math . max ( leftMargin , Math . min ( x , ( ( clientAreaWidth ) - ( rightMargin ) ) ) ) ; y = Math . max ( topMargin , Math . min ( y , ( ( clientAreaHeight ) - ( bottomMargin ) ) ) ) ; if ( ( doubleClickEnabled ) && ( ( clickCount ) > 1 ) ) { boolean wordSelect = ( ( clickCount ) & 1 ) == 0 ; if ( wordSelect ) { Point left = getPointAtOffset ( doubleClickSelection . x ) ; int [ ] trailing = new int [ 1 ] ; int offset = getOffsetAtPoint ( x , y , trailing , true ) ; if ( offset != ( - 1 ) ) { if ( x > ( left . x ) ) { offset = getWordNext ( ( offset + ( trailing [ 0 ] ) ) , MOVEMENT_WORD_END ) ; setBlockSelectionOffset ( doubleClickSelection . x , offset , true ) ; } else { offset = getWordPrevious ( ( offset + ( trailing [ 0 ] ) ) , MOVEMENT_WORD_START ) ; setBlockSelectionOffset ( doubleClickSelection . y , offset , true ) ; } } else { if ( x > ( left . x ) ) { setBlockSelectionLocation ( left . x , left . y , x , y , true ) ; } else { Point right = getPointAtOffset ( doubleClickSelection . y ) ; setBlockSelectionLocation ( right . x , right . y , x , y , true ) ; } } } else { setBlockSelectionLocation ( blockXLocation , y , true ) ; } return ; } else { if ( ! select ) clearBlockSelection ( true , false ) ; int [ ] trailing = new int [ 1 ] ; int offset = getOffsetAtPoint ( x , y , trailing , true ) ; if ( offset != ( - 1 ) ) { if ( select ) { setBlockSelectionOffset ( ( offset + ( trailing [ 0 ] ) ) , true ) ; return ; } } else { if ( ( isFixedLineHeight ( ) ) && ( renderer . fixedPitch ) ) { int avg = renderer . averageCharWidth ; <START_BUG> x = ( ( ( x + ( horizontalScrollOffset ) ) // avg ) * avg ) - ( horizontalScrollOffset ) ; <END_BUG> } setBlockSelectionLocation ( x , y , true ) ; return ; } } } if ( ( line < 0 ) || ( ( isSingleLine ( ) ) && ( line > 0 ) ) ) { return ; } int [ ] alignment = new int [ 1 ] ; int newCaretOffset = getOffsetAtPoint ( x , y , alignment ) ; int newCaretAlignemnt = alignment [ 0 ] ; if ( ( doubleClickEnabled ) && ( ( clickCount ) > 1 ) ) { newCaretOffset = doMouseWordSelect ( x , newCaretOffset , line ) ; } int newCaretLine = content . getLineAtOffset ( newCaretOffset ) ; if ( ( ( 0 <= y ) && ( y < ( clientAreaHeight ) ) ) && ( ( ( ( 0 <= x ) && ( x < ( clientAreaWidth ) ) ) || ( wordWrap ) ) || ( newCaretLine != ( content . getLineAtOffset ( caretOffset ) ) ) ) ) { if ( ( newCaretOffset != ( caretOffset ) ) || ( newCaretAlignemnt != ( caretAlignment ) ) ) { setCaretOffset ( newCaretOffset , newCaretAlignemnt ) ; if ( select ) doMouseSelection ( ) ; showCaret ( ) ; } } if ( ! select ) { setCaretOffset ( newCaretOffset , newCaretAlignemnt ) ; clearSelection ( true ) ; } } void doMouseSelection ( ) { } int doMouseWordSelect ( int x , int newCaretOffset , int line ) { } void doPageDown ( boolean select , int height ) { } void doPageEnd ( ) { } void doPageStart ( ) { } void doPageUp ( boolean select , int height ) { } void doSelection ( int direction ) { } void doSelectionCursorNext ( ) { } void doSelectionCursorPrevious ( ) { } void doSelectionLineDown ( ) { } void doSelectionLineUp ( ) { }

Fix:
x = ( ( ( ( x + ( horizontalScrollOffset ) ) // avg ) * avg ) - ( horizontalScrollOffset ) ) + ( leftMargin ) ;