Fixed redo not working correctly

This commit is contained in:
Kah Wei 2022-11-13 13:16:36 +08:00
parent a83a38eba8
commit 635d999c2c
1 changed files with 5 additions and 3 deletions

View File

@ -34,7 +34,8 @@ namespace SHADE
bool UndoRedoStack::RedoActionPresent::get()
{
return latestActionIndex >= 0 && latestActionIndex < commandStack->Count - 1;
const int REDO_ACTION_INDEX = latestActionIndex + 1;
return REDO_ACTION_INDEX >= 0 && REDO_ACTION_INDEX < commandStack->Count;
}
/*---------------------------------------------------------------------------------*/
@ -69,8 +70,9 @@ namespace SHADE
{
if (!RedoActionPresent)
return;
ICommand^ cmd = commandStack[latestActionIndex];
const int REDO_ACTION_INDEX = latestActionIndex + 1;
ICommand^ cmd = commandStack[REDO_ACTION_INDEX];
cmd->Execute();
++latestActionIndex;
}