public void EndUndoGroup()
{
if (undoGroupDepth == 0) throw new InvalidOperationException("There are no open undo groups");
undoGroupDepth--;
//Util.LoggingService.Debug("Close undo group (new depth=" + undoGroupDepth + ")");
if (undoGroupDepth == 0)
{
Debug.Assert(state == StateListen || actionCountInUndoGroup == 0);
allowContinue = true;
if (actionCountInUndoGroup == optionalActionCount)
{
// only optional actions: don't store them
for (var i = 0; i < optionalActionCount; i++)
{
undostack.PopBack();
}
allowContinue = false;
}
else if (actionCountInUndoGroup > 1)
{
// combine all actions within the group into a single grouped action
undostack.PushBack(new UndoOperationGroup(undostack, actionCountInUndoGroup));
FileModified(-actionCountInUndoGroup + 1 + optionalActionCount);
}
//if (state == StateListen) {
EnforceSizeLimit();
RecalcIsOriginalFile(); // can raise event
//}
}
}