Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Redo #100

Merged
merged 2 commits into from
Oct 28, 2021
Merged

Conversation

yeppog
Copy link

@yeppog yeppog commented Oct 28, 2021

Allows for Redo-ing a command that has been undone

  • Changes the implementation for CommandHistory to be a custom doubly linked list to allow for pointer storage.
  • Stack now persists even after undo-ing to allow for redo-ing
  • Stack purges the head of the linked list after exceeding the maximum stack size, which can be defined in the constructor.
  • Redo simply re executes() the stored Command on the stack

Intended behaviour

  • When undoing commands, if a new command is executed, the history points of Commands executed after the current undo point will be lost. For example:
Stack:
null <-> add 1 <-> add 2 <-> add 3 <-> null
                                        ^current
Stack after undoing twice:
null <-> add 1 <-> add 2 <-> add 3 <-> null
                    ^current

Stack after adding a new command:
null <-> add 1 <-> add 7 <-> null
                               ^current
  • Current will always point to null to signify that it is at the top of the stack

@yeppog yeppog requested a review from jeffsieu October 28, 2021 06:27
@yeppog yeppog added this to the v1.3 milestone Oct 28, 2021
@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2021

Codecov Report

Merging #100 (b317bf3) into master (223e831) will increase coverage by 0.01%.
The diff coverage is 51.42%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #100      +/-   ##
============================================
+ Coverage     58.40%   58.41%   +0.01%     
- Complexity      591      599       +8     
============================================
  Files           120      121       +1     
  Lines          2505     2561      +56     
  Branches        240      251      +11     
============================================
+ Hits           1463     1496      +33     
- Misses          953      975      +22     
- Partials         89       90       +1     
Impacted Files Coverage Δ
...rc/main/java/seedu/address/logic/LogicManager.java 36.73% <0.00%> (-2.40%) ⬇️
...java/seedu/address/logic/commands/RedoCommand.java 0.00% <0.00%> (ø)
.../seedu/address/logic/parser/AddressBookParser.java 80.00% <0.00%> (-4.22%) ⬇️
src/main/java/seedu/address/model/Model.java 100.00% <ø> (ø)
src/main/java/seedu/address/ui/MainWindow.java 0.00% <0.00%> (ø)
...java/seedu/address/logic/commands/UndoCommand.java 57.14% <33.33%> (ø)
src/main/java/seedu/address/model/TaskList.java 67.85% <33.33%> (-4.15%) ⬇️
...ain/java/seedu/address/storage/CommandHistory.java 70.00% <69.76%> (+20.00%) ⬆️
...du/address/logic/commands/task/AddTaskCommand.java 72.72% <100.00%> (+18.18%) ⬆️
...rc/main/java/seedu/address/model/ModelManager.java 81.92% <100.00%> (+0.31%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 223e831...b317bf3. Read the comment docs.

@yeppog yeppog added priority.High type.Enhancement An enhancement to an existing story labels Oct 28, 2021
Undo broke due to new equalsTo implementation for tasks.
Copy link

@jeffsieu jeffsieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jeffsieu jeffsieu merged commit 2b444a5 into AY2122S1-CS2103-F09-2:master Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority.High type.Enhancement An enhancement to an existing story
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants