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++) {