Fix history was not updated correctly on new action

Fix a bug where the history was broken when an action is executed after a undo operation.