[nostalgia/studio] Make UndoCommand::redo execute as soon as pushed

This commit is contained in:
Gary Talent 2022-02-13 23:22:48 -06:00
parent 3785d192f9
commit 4f69f027ef

View File

@ -12,14 +12,19 @@ void UndoStack::push(UndoCommand *cmd) noexcept {
}
m_stack.emplace_back(cmd);
++m_stackIdx;
cmd->redo();
}
void UndoStack::redo() noexcept {
m_stack[m_stackIdx++]->redo();
if (m_stackIdx < m_stack.size()) {
m_stack[m_stackIdx++]->redo();
}
}
void UndoStack::undo() noexcept {
m_stack[m_stackIdx--]->undo();
if (m_stackIdx < ox::MaxValue<decltype(m_stackIdx)>) {
m_stack[m_stackIdx--]->undo();
}
}
}