void (DocumentEvent e) { if (myScrollPane == null) return; stopOptimizedScrolling(); mySelectionModel.removeBlockSelection(); mySizeContainer.changedUpdate(e); int startVisualLine = offsetToVisualPosition(e.getOffset()).line; int endVisualLine = offsetToVisualPosition(e.getOffset() + e.getNewLength()).line; if (myDocument.getTextLength() > 0) { int startDocLine = myDocument.getLineNumber(e.getOffset()); int endDocLine = myDocument.getLineNumber(e.getOffset() + e.getNewLength()); if (e.getOldLength() > e.getNewLength() || startDocLine != endDocLine) { updateGutterSize(); } } updateCaretCursor(); repaintLines(startVisualLine, endVisualLine); Point caretLocation = visualPositionToXY(getCaretModel().getVisualPosition()); int scrollOffset = caretLocation.y - myCaretUpdateVShift; getScrollingModel().scrollVertically(scrollOffset); }