Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix limit for history stack size #1001

Merged
merged 1 commit into from
Sep 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix limit for history stack size
  • Loading branch information
Evan Solomon committed Sep 23, 2016
commit 2bf1905fafc77f72414ff8d293be0d1ff0918e9c
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