File tree Expand file tree Collapse file tree 1 file changed +3
-14
lines changed
src/main/java/seedu/address/history Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Original file line number Diff line number Diff line change @@ -87,22 +87,11 @@ private boolean hasNextCommand() {
8787 @ Override
8888 public void addToHistory (String command ) {
8989 hasReturnedCurrentCommandBefore = false ;
90- if (hasNextCommand ()) {
91- // if there exist a next command,
92- // copy commandHistory[0] to commandHistory[currentCommandIndex],
93- // store it as the new commandHistory
94- // and append the new command.
95- commandHistory = commandHistory .subList (0 , currentCommandIndex + 1 );
96- this .currentCommandIndex ++;
97- this .commandHistory .add (command );
98- } else if (isLimitReached ()) {
90+ if (isLimitReached ()) {
9991 this .commandHistory .remove (0 );
100- this .commandHistory .add (command );
101- } else {
102- // when there is sufficient space for nextCommand to be added to history
103- this .currentCommandIndex ++;
104- this .commandHistory .add (command );
10592 }
93+ this .commandHistory .add (command );
94+ this .currentCommandIndex = commandHistory .size () - 1 ;
10695 }
10796
10897 @ Override
You can’t perform that action at this time.
0 commit comments