void (DocumentEvent e) { myDocumentChangeInProgress = false; if (myDocument.isInBulkUpdate()) return; if (myErrorStripeNeedsRepaint) { myMarkupModel.repaint(e.getOffset(), e.getOffset() + e.getNewLength()); myErrorStripeNeedsRepaint = false; } clearTextWidthCache(); setMouseSelectionState(MOUSE_SELECTION_STATE_NONE); // We assume that size container is already notified with the visual line widths during soft wraps processing if (!mySoftWrapModel.isSoftWrappingEnabled() && !myUseNewRendering) { mySizeContainer.changedUpdate(e); } validateSize(); int startLine = offsetToLogicalLine(e.getOffset()); int endLine = offsetToLogicalLine(e.getOffset() + e.getNewLength()); boolean painted = false; 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 || StringUtil.indexOf(e.getOldFragment(), '\n') != -1) { updateGutterSize(); } if (countLineFeeds(e.getOldFragment()) != countLineFeeds(e.getNewFragment())) { // Lines removed. Need to repaint till the end of the screen repaintToScreenBottom(startLine); painted = true; } } updateCaretCursor(); if (!painted) { repaintLines(startLine, endLine); } if (getCaretModel().getOffset() < e.getOffset() || getCaretModel().getOffset() > e.getOffset() + e.getNewLength()){ restoreCaretRelativePosition(); } }