private void doChange(int fromLength, Object to, int toLength, long toTimeStamp) throws UnexpectedUndoException {
    //noinspection ConstantConditions
    DocumentImpl document = (DocumentImpl)getAffectedDocuments()[0].getDocument();
    assert document != null;
    if (document.getTextLength() != fromLength) throw new UnexpectedUndoException("Unexpected document state");

    DocumentUndoProvider.startDocumentUndo(document);
    try {
      CharSequence toString = CompressionUtil.uncompressStringRawBytes(to);
      int fromStringLength = toString.length() - toLength + fromLength;
      int offset = myChangeRange.getState().getOffset();
      int moveOffset = myChangeRange.isMoved() ? offset : myMoveOffset;
      document.replaceString(offset, offset + fromStringLength, moveOffset, toString, toTimeStamp, false);
    }
    finally {
      DocumentUndoProvider.finishDocumentUndo(document);
    }
  }
private void doChange(int fromLength, Object to, int toLength, long toTimeStamp)