@@ -70,10 +70,10 @@ History.prototype = {
7070 cmd . id = ++ this . idCounter ;
7171
7272 }
73- cmd . name = optionalName !== undefined ? optionalName : cmd . name ;
73+ cmd . name = ( optionalName !== undefined ) ? optionalName : cmd . name ;
7474 cmd . execute ( ) ;
7575 cmd . inMemory = true ;
76- cmd . json = cmd . toJSON ( ) ; // serialize cmd immediately after execution
76+ cmd . json = cmd . toJSON ( ) ; // serialize the cmd immediately after execution and append the json to the cmd
7777
7878 this . lastCmdTime = new Date ( ) ;
7979
@@ -164,8 +164,7 @@ History.prototype = {
164164
165165 for ( var i = 0 ; i < this . undos . length ; i ++ ) {
166166
167- var cmd = this . undos [ i ] ;
168- undos . push ( cmd . json ) ;
167+ undos . push ( this . undos [ i ] . json ) ;
169168
170169 }
171170
@@ -177,8 +176,7 @@ History.prototype = {
177176
178177 for ( var i = 0 ; i < this . redos . length ; i ++ ) {
179178
180- var cmd = this . redos [ i ] ;
181- redos . push ( cmd . json ) ;
179+ redos . push ( this . redos [ i ] . json ) ;
182180
183181 }
184182
@@ -198,7 +196,7 @@ History.prototype = {
198196 var cmd = new window [ cmdJSON . type ] ( ) ; // creates a new object of type "json.type"
199197 cmd . json = cmdJSON ;
200198 this . undos . push ( cmd ) ;
201- this . idCounter = cmdJSON . id > this . idCounter ? cmdJSON . id : this . idCounter ; // set last used idCounter
199+ this . idCounter = ( cmdJSON . id > this . idCounter ) ? cmdJSON . id : this . idCounter ; // set last used idCounter
202200
203201 }
204202
@@ -208,11 +206,12 @@ History.prototype = {
208206 var cmd = new window [ cmdJSON . type ] ( ) ; // creates a new object of type "json.type"
209207 cmd . json = cmdJSON ;
210208 this . redos . push ( cmd ) ;
211- this . idCounter = cmdJSON . id > this . idCounter ? cmdJSON . id : this . idCounter ; // set last used idCounter
209+ this . idCounter = ( cmdJSON . id > this . idCounter ) ? cmdJSON . id : this . idCounter ; // set last used idCounter
212210
213211 }
214212
215- this . editor . signals . historyChanged . dispatch ( ) ;
213+ // Select the last executed undo-command
214+ this . editor . signals . historyChanged . dispatch ( this . undos [ this . undos . length - 1 ] ) ;
216215
217216 } ,
218217
0 commit comments