void (@NotNull UndoableAction action) { if (action instanceof AdjustableUndoableAction adjustable) { DocumentReference[] affected = action.getAffectedDocuments(); if (affected == null) { return; } for (DocumentReference reference : affected) { for (ActionChangeRange changeRange : adjustable.getChangeRanges(reference)) { myManager.getSharedUndoStacksHolder().addToStack(reference, changeRange); myManager.getSharedRedoStacksHolder().addToStack(reference, changeRange.createIndependentCopy(true)); } } } }