Force Move History refresh after loading/reverting variation
[xboard.git] / backend.c
index a304ca5..b1e5e93 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -10462,6 +10462,7 @@ Reset(redraw, init)
                redraw, init, gameMode);
     }
     CleanupTail(); // [HGM] vari: delete any stored variations
+    CommentPopDown(); // [HGM] make sure no comments to the previous game keep hanging on
     pausing = pauseExamInvalid = FALSE;
     startedFromSetupPosition = blackPlaysFirst = FALSE;
     firstMove = TRUE;
@@ -16442,8 +16443,8 @@ PopInner(Boolean annotate)
        int i, j, nrMoves;
        char buf[8000], moveBuf[20];
 
-       storedGames--;
-       ToNrEvent(savedFirst[storedGames]); // sets currentMove
+       ToNrEvent(savedFirst[storedGames-1]); // sets currentMove
+       storedGames--; // do this after ToNrEvent, to make sure HistorySet will refresh entire game after PopInner returns
        nrMoves = savedLast[storedGames] - currentMove;
        if(annotate) {
                int cnt = 10;
@@ -16491,6 +16492,7 @@ PopTail(Boolean annotate)
        CommentPopDown(); // make sure no stale variation comments to the destroyed line can remain open
 
        PopInner(annotate);
+       HistorySet(parseList, backwardMostMove, forwardMostMove, currentMove-1);
 
        if(storedGames == 0) GreyRevert(TRUE);
        return TRUE;