Skip to content

Commit

Permalink
Fix limit for history stack size
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Solomon committed Sep 23, 2016
1 parent 62454a3 commit 1b8ddf4
Show file tree
Hide file tree
Showing 2 changed files with 15 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
14 changes: 14 additions & 0 deletions test/unit/modules/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ 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, 'user'));
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 1b8ddf4

Please sign in to comment.