This PR fixes a bug identified in issue #287 by the commandLog after each load command to prevent unexpected behaviors with undo.
The undo command was implemented using a commandLog, which is a Stack storing all commands previously executed.
The undo after load bug arises because while we load a different addressBook state, the commandLog persists and allows users to undo commands that do not apply to the loaded addressBook. For example, try this sequence of commands in our 1.5.1 release:
Run a clear command to obtain an empty addressBook
Run a save command on this empty addressBook
Run an add command, like add n/test
Run load command to return to the empty addressBook
Run undo and see an exception in the terminal
In this case, GamerBook is trying to undo the add command on the loaded empty state! The user will be exposed to an exception because we are trying to delete a non-existant person. This is just one of many possible unexpected behaviors arising from this functionality bug.
This PR does not violate the feature freeze by Q3, as we are fixing a bug to ensure that undo after load follows reasonably correct behavior.
This PR fixes a bug identified in issue #287 by the commandLog after each
load
command to prevent unexpected behaviors withundo
.The undo command was implemented using a
commandLog
, which is aStack
storing all commands previously executed.The
undo
afterload
bug arises because while we load a different addressBook state, thecommandLog
persists and allows users to undo commands that do not apply to the loaded addressBook. For example, try this sequence of commands in our 1.5.1 release:clear
command to obtain an empty addressBooksave
command on this empty addressBookadd
command, likeadd n/test
load
command to return to the empty addressBookundo
and see an exception in the terminalIn this case, GamerBook is trying to
undo
theadd
command on the loaded empty state! The user will be exposed to an exception because we are trying to delete a non-existant person. This is just one of many possible unexpected behaviors arising from this functionality bug.This PR does not violate the feature freeze by Q3, as we are fixing a bug to ensure that
undo
afterload
follows reasonably correct behavior.