Permalink
Browse files

Fix Stack._clearRedo

  • Loading branch information...
1 parent 8ec4739 commit 5a482cd46819d7ac46245811e3e191597826fdb9 @jzaefferer committed Feb 28, 2011
Showing with 19 additions and 2 deletions.
  1. +18 −0 tests/core.js
  2. +1 −2 undo.js
View
@@ -64,3 +64,21 @@ test("Stack", function() {
ok( stack.canUndo() );
ok( !stack.canRedo() );
});
+
+test("Stack._clearRedo", function() {
+ var object = {
+ name: "Peter"
+ }
+ var command = new NameChange(object, "p0wn");
+ var stack = new Undo.Stack();
+
+ stack.execute(command)
+ stack.execute(command)
+ stack.execute(command)
+ stack.undo();
+ stack.undo();
+ stack.undo();
+
+ stack.execute(command);
+ ok( !stack.canRedo() );
+});
View
@@ -85,8 +85,7 @@ extend(Undo.Stack.prototype, {
},
_clearRedo: function() {
// TODO there's probably a more efficient way for this
- // FIXME
- //this.commands = this.commands.slice(0, this.stackPosition);
+ this.commands = this.commands.slice(0, this.stackPosition + 1);
},
changed: function() {
// do nothing, override

0 comments on commit 5a482cd

Please sign in to comment.