diff --git a/editor/js/Cmd.js b/editor/js/Cmd.js index 954fce4b238904b4326593f567f4024fb0bc45c1..f3b43315bba5b91cc0043ad7aa96b08a5c50ebb8 100755 --- a/editor/js/Cmd.js +++ b/editor/js/Cmd.js @@ -36,6 +36,5 @@ Cmd.prototype.fromJSON = function ( json ) { this.type = json.type; this.id = json.id; this.name = json.name; - this.json = json; }; \ No newline at end of file diff --git a/editor/js/History.js b/editor/js/History.js index 0a71ada501f24b2e3e9eb83dbbbb4766bf339312..58305926ef2d671e80b13c72117bba8e07b945fc 100644 --- a/editor/js/History.js +++ b/editor/js/History.js @@ -70,10 +70,10 @@ History.prototype = { cmd.id = ++this.idCounter; } - cmd.name = optionalName !== undefined ? optionalName : cmd.name; + cmd.name = ( optionalName !== undefined ) ? optionalName : cmd.name; cmd.execute(); cmd.inMemory = true; - cmd.json = cmd.toJSON(); // serialize cmd immediately after execution + cmd.json = cmd.toJSON(); // serialize the cmd immediately after execution and append the json to the cmd this.lastCmdTime = new Date(); @@ -164,8 +164,7 @@ History.prototype = { for ( var i = 0 ; i < this.undos.length; i++ ) { - var cmd = this.undos[ i ]; - undos.push( cmd.json ); + undos.push( this.undos[ i ].json ); } @@ -177,8 +176,7 @@ History.prototype = { for ( var i = 0 ; i < this.redos.length; i++ ) { - var cmd = this.redos[ i ]; - redos.push( cmd.json ); + redos.push( this.redos[ i ].json ); } @@ -198,7 +196,7 @@ History.prototype = { var cmd = new window[ cmdJSON.type ](); // creates a new object of type "json.type" cmd.json = cmdJSON; this.undos.push( cmd ); - this.idCounter = cmdJSON.id > this.idCounter ? cmdJSON.id : this.idCounter; // set last used idCounter + this.idCounter = ( cmdJSON.id > this.idCounter ) ? cmdJSON.id : this.idCounter; // set last used idCounter } @@ -208,11 +206,12 @@ History.prototype = { var cmd = new window[ cmdJSON.type ](); // creates a new object of type "json.type" cmd.json = cmdJSON; this.redos.push( cmd ); - this.idCounter = cmdJSON.id > this.idCounter ? cmdJSON.id : this.idCounter; // set last used idCounter + this.idCounter = ( cmdJSON.id > this.idCounter ) ? cmdJSON.id : this.idCounter; // set last used idCounter } - this.editor.signals.historyChanged.dispatch(); + // Select the last executed undo-command + this.editor.signals.historyChanged.dispatch( this.undos[ this.undos.length - 1 ] ); }, diff --git a/test/unit/editor/TestSerialization.js b/test/unit/editor/TestSerialization.js index ae7e2b4f63c53eb420498d66ca901fe464f6346f..80680779a814688c0152eae9278977783873979a 100755 --- a/test/unit/editor/TestSerialization.js +++ b/test/unit/editor/TestSerialization.js @@ -1,6 +1,6 @@ module( "Serialization" ); -test( "Test Serialization (simple)", function() { +test( "Test Serialization", function() { // setup var editor = new Editor();