Buggy code:
public void insert ( String string ) { } void installDefaultContent ( ) { } void installDefaultLineStyler ( ) { } void installListeners ( ) { } void internalRedrawRange ( int start , int length , boolean clearBackground ) { } void handleDispose ( Event event ) { } void handleHorizontalScroll ( Event event ) { } void handleKey ( Event event ) { } void handleKeyDown ( Event event ) { } void handleKeyUp ( Event event ) { } void handleMouseDoubleClick ( 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 ( ) { } void initializeRenderer ( ) { } public void invokeAction ( int action ) { } boolean isBidi ( ) { } boolean isLineDelimiter ( int offset ) { } boolean isMirrored ( ) { } boolean isAreaVisible ( int firstLine , int lastLine ) { } boolean isSingleLine ( ) { } void modifyContent ( Event event , boolean updateCaret ) { } public void paste ( ) { } public void print ( ) { } public Runnable print ( Printer printer ) { } public Runnable print ( Printer printer , StyledTextPrintOptions options ) { } public void redraw ( ) { } public void redraw ( int x , int y , int width , int height , boolean all ) { } public void redrawRange ( int start , int length , boolean clearBackground ) { } public void removeBidiSegmentListener ( BidiSegmentListener listener ) { } public void removeExtendedModifyListener ( ExtendedModifyListener extendedModifyListener ) { } public void removeLineBackgroundListener ( LineBackgroundListener listener ) { } public void removeLineStyleListener ( LineStyleListener listener ) { } public void removeModifyListener ( ModifyListener modifyListener ) { } public void removeSelectionListener ( SelectionListener listener ) { } public void removeVerifyListener ( VerifyListener verifyListener ) { } public void removeVerifyKeyListener ( VerifyKeyListener 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 ( ) { } boolean scrollHorizontal ( int pixels , boolean adjustScrollBar ) { } boolean scrollVertical ( int pixels , boolean adjustScrollBar ) { } void scroll ( int hscroll , int vscroll ) { } public void selectAll ( ) { } void sendKeyEvent ( Event event ) { } StyledTextEvent sendLineEvent ( int eventType , int lineOffset , String line ) { } void sendModifyEvent ( Event event ) { } void sendSelectionEvent ( ) { } public void setWordWrap ( boolean wrap ) { } public void setCaret ( Caret caret ) { } public void setBackground ( Color color ) { } public void setBidiColoring ( boolean mode ) { } void setCaretLocation ( ) { } void setCaretLocation ( Point location , int direction ) { Caret caret = getCaret ( ) ; if ( caret != null ) { int caretHeight = lineHeight ; if ( ! ( isFixedLineHeight ( ) ) ) { int caretLine = content . getLineAtOffset ( caretOffset ) ; int lineOffset = content . getOffsetAtLine ( caretLine ) ; String text = content . getLine ( caretLine ) ; TextLayout layout = renderer . getTextLayout ( text , lineOffset ) ; int lineInParagraph = layout . getLineIndex ( ( ( caretOffset ) - lineOffset ) ) ; <START_BUG> caretHeight = ( layout . getLineBounds ( lineInParagraph ) . height ) - ( lineSpacing ) ; <END_BUG> renderer . disposeTextLayout ( layout ) ; if ( caretHeight != ( lineHeight ) ) { direction = SWT . DEFAULT ; } } boolean updateImage = caret == ( defaultCaret ) ; int imageDirection = direction ; if ( isMirrored ( ) ) { if ( imageDirection == ( SWT . LEFT ) ) { imageDirection = SWT . RIGHT ; } else if ( imageDirection == ( SWT . RIGHT ) ) { imageDirection = SWT . LEFT ; } } if ( updateImage && ( imageDirection == ( SWT . RIGHT ) ) ) { location . x -= ( caret . getSize ( ) . x ) - 1 ; } caret . setBounds ( location . x , location . y , 0 , caretHeight ) ; getAccessible ( ) . textCaretMoved ( getCaretOffset ( ) ) ; if ( direction != ( caretDirection ) ) { caretDirection = direction ; if ( updateImage ) { if ( imageDirection == ( SWT . DEFAULT ) ) { defaultCaret . setImage ( null ) ; } else if ( imageDirection == ( SWT . LEFT ) ) { defaultCaret . setImage ( leftCaretBitmap ) ; } else if ( imageDirection == ( SWT . RIGHT ) ) { defaultCaret . setImage ( rightCaretBitmap ) ; } } if ( ( caretDirection ) == ( SWT . LEFT ) ) { BidiUtil . setKeyboardLanguage ( KEYBOARD_NON_BIDI ) ; } else if ( ( caretDirection ) == ( SWT . RIGHT ) ) { BidiUtil . setKeyboardLanguage ( KEYBOARD_BIDI ) ; } } } columnX = location . x ; } 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 ) { }

Fix:
caretHeight = layout . getLineBounds ( lineInParagraph ) . height ;