From 7531b323b272f1210bd3be00104410dadb4e65e5 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Fri, 12 Oct 2018 06:34:23 -0700 Subject: [PATCH] Honour reductions to MAX_UNDO (#2078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Honour reductions to MAX_UNDO If MAX_UNDO is reduced, we now throw away the extra records in the stack, as opposed to just not growing it anymore. * shift != unshift Apparently I need a new brain. * Ensure MAX_UNDO isn’t negative. --- core/workspace.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/workspace.js b/core/workspace.js index 2454e2ae9..5343968aa 100644 --- a/core/workspace.js +++ b/core/workspace.js @@ -523,8 +523,8 @@ Blockly.Workspace.prototype.fireChangeListener = function(event) { if (event.recordUndo) { this.undoStack_.push(event); this.redoStack_.length = 0; - if (this.undoStack_.length > this.MAX_UNDO) { - this.undoStack_.unshift(); + while (this.undoStack_.length > this.MAX_UNDO && this.MAX_UNDO >= 0) { + this.undoStack_.shift(); } } for (var i = 0, func; func = this.listeners_[i]; i++) {