Fix enter/exit analyze mode in the middle of a multi-move
[vchess.git] / client / src / components / BaseGame.vue
index 3d8e7eb..a1af478 100644 (file)
@@ -258,8 +258,11 @@ export default {
       else this.lastMove = null;
     },
     toggleAnalyze: function() {
+      // Autoplay has priority:
+      if (this.autoplay) return;
       if (this.mode != "analyze") {
         // Enter analyze mode:
+        if (this.inMultimove) this.cancelCurrentMultimove();
         this.gameMode = this.mode; //was not 'analyze'
         this.mode = "analyze";
         this.gameCursor = this.cursor;
@@ -278,6 +281,7 @@ export default {
           fen = mv[mv.length-1].fen;
         }
         this.vr = new V(fen);
+        this.inMultimove = false; //in case of
         this.incheck = this.vr.getCheckSquares();
         if (this.cursor >= 0) this.lastMove = this.moves[this.cursor];
         else this.lastMove = null;