Skip to content

Commit

Permalink
Fix limit for history stack size (#1001)
Browse files Browse the repository at this point in the history
  • Loading branch information
evansolomon authored and jhchen committed Sep 23, 2016
1 parent 47993e5 commit 2339778
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class History extends Module {
undo: undoDelta
});
if (this.stack.undo.length > this.options.maxStack) {
this.stack.undo.unshift();
this.stack.undo.shift();
}
}

Expand Down
11 changes: 11 additions & 0 deletions test/unit/modules/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ describe('History', function() {
this.original = this.quill.getContents();
});

it('limits undo stack size', function () {
let quill = new Quill(this.container.firstChild, {
modules: {
history: {delay: 0, maxStack: 2}
}
});

['A', 'B', 'C'].forEach(text => quill.insertText(0, text));
expect(quill.history.stack.undo.length).toEqual(2);
});

it('user change', function() {
this.quill.root.firstChild.innerHTML = 'The lazy foxes';
this.quill.update();
Expand Down

0 comments on commit 2339778

Please sign in to comment.