void (@NotNull DocumentEvent e) { myDocumentChangeInProgress = false; if (myDocument.isInBulkUpdate()) return; if (myErrorStripeNeedsRepaint) { myMarkupModel.repaint(e.getOffset(), e.getOffset() + e.getNewLength()); myErrorStripeNeedsRepaint = false; } setMouseSelectionState(MOUSE_SELECTION_STATE_NONE); if (myGutterComponent.getCurrentAccessibleLine() != null) { escapeGutterAccessibleLine(e.getOffset(), e.getOffset() + e.getNewLength()); } validateSize(); int startLine = offsetToLogicalLine(e.getOffset()); int endLine = offsetToLogicalLine(e.getOffset() + e.getNewLength()); if (startLine != endLine || StringUtil.indexOf(e.getOldFragment(), '\n') != -1) { myGutterComponent.clearLineToGutterRenderersCache(); } if (myRangeToRepaintStart < myDocument.getLineStartOffset(startLine)) { startLine = myDocument.getLineNumber(myRangeToRepaintStart); } if (myRangeToRepaintEnd > myDocument.getLineEndOffset(endLine)) { endLine = myDocument.getLineNumber(Math.min(myRangeToRepaintEnd, myDocument.getTextLength())); } if (countLineFeeds(e.getOldFragment()) != countLineFeeds(e.getNewFragment())) { // Lines removed. Need to repaint till the end of the screen repaintToScreenBottom(startLine); } else { repaintLines(startLine, endLine); } updateCaretCursor(); if (myRestoreScrollingPosition && !Boolean.TRUE.equals(getUserData(DISABLE_CARET_POSITION_KEEPING)) && myScrollingPositionKeeper != null) { myScrollingPositionKeeper.restorePosition(true); } }