fix: undo and redo both work
This commit is contained in:
parent
e2926f7c3f
commit
07db1670c7
2 changed files with 37 additions and 23 deletions
|
|
@ -1,5 +1,4 @@
|
|||
#include "edit_history.h"
|
||||
#include "macros.h"
|
||||
|
||||
EditHistory *EditHistory::singleton_instance{ nullptr };
|
||||
|
||||
|
|
@ -19,15 +18,15 @@ void EditHistory::push_action(Callable do_action, Callable undo_action) {
|
|||
}
|
||||
|
||||
void EditHistory::undo() {
|
||||
if (this->undo_count + 1 < this->history.size()) {
|
||||
if (this->undo_count < this->history.size()) {
|
||||
this->undo_count++;
|
||||
this->history[this->history.size() - this->undo_count].undo_action.call();
|
||||
}
|
||||
}
|
||||
|
||||
void EditHistory::redo() {
|
||||
if (this->undo_count > 1) {
|
||||
this->undo_count--;
|
||||
if (this->undo_count > 0) {
|
||||
this->history[this->history.size() - this->undo_count].do_action.call();
|
||||
this->undo_count--;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue