diff --git a/src/UndoManager.cpp b/src/UndoManager.cpp index 4b6f564d0..2eca7c1f8 100644 --- a/src/UndoManager.cpp +++ b/src/UndoManager.cpp @@ -61,7 +61,6 @@ UndoManager::UndoManager() { current = -1; saved = -1; - consolidationCount = 0; ResetODChangesFlag(); } @@ -257,10 +256,9 @@ void UndoManager::PushState(const TrackList * l, { unsigned int i; - // If consolidate is set to true, group up to 3 identical operations. - if (((flags & UndoPush::CONSOLIDATE) != UndoPush::MINIMAL) && lastAction == longDescription && - consolidationCount < 2) { - consolidationCount++; + if ( ((flags & UndoPush::CONSOLIDATE) != UndoPush::MINIMAL) && + lastAction == longDescription && + mayConsolidate ) { ModifyState(l, selectedRegion, tags); // MB: If the "saved" state was modified by ModifyState, reset // it so that UnsavedChanges returns true. @@ -270,7 +268,7 @@ void UndoManager::PushState(const TrackList * l, return; } - consolidationCount = 0; + mayConsolidate = true; i = current + 1; while (i < stack.size()) { @@ -319,7 +317,7 @@ const UndoState &UndoManager::SetStateTo } lastAction = wxT(""); - consolidationCount = 0; + mayConsolidate = false; return stack[current]->state; } @@ -333,7 +331,7 @@ const UndoState &UndoManager::Undo(SelectedRegion *selectedRegion) *selectedRegion = stack[current]->state.selectedRegion; lastAction = wxT(""); - consolidationCount = 0; + mayConsolidate = false; return stack[current]->state; } @@ -360,7 +358,7 @@ const UndoState &UndoManager::Redo(SelectedRegion *selectedRegion) */ lastAction = wxT(""); - consolidationCount = 0; + mayConsolidate = false; return stack[current]->state; } diff --git a/src/UndoManager.h b/src/UndoManager.h index f4108ea3f..d64474203 100644 --- a/src/UndoManager.h +++ b/src/UndoManager.h @@ -30,8 +30,9 @@ UndoManager can also automatically consolidate actions into a single state change. If the "consolidate" argument to - PushState is true, then up to 3 identical events in a row - will result in one PushState and 2 ModifyStates. + PushState is true, then new changes may accumulate into the most + recent Undo state, if descriptions match and if no Undo or Redo or rollback + operation intervened since that state was pushed. Undo() temporarily moves down one state and returns the track hierarchy. If another PushState is called, the redo information @@ -143,7 +144,7 @@ class AUDACITY_DLL_API UndoManager { UndoStack stack; wxString lastAction; - int consolidationCount; + bool mayConsolidate { false }; SpaceArray space; unsigned long long mClipboardSpaceUsage {};