From 0f12bd9b596d77d8fb3b28823e504b8f02b813d0 Mon Sep 17 00:00:00 2001 From: Neil Kandalgaonkar Date: Thu, 1 Dec 2011 19:08:24 +0000 Subject: [PATCH] get rid of separate undoState function --- modules/es/models/es.SurfaceModel.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/es/models/es.SurfaceModel.js b/modules/es/models/es.SurfaceModel.js index 560d558b1b..8e94fbdefd 100644 --- a/modules/es/models/es.SurfaceModel.js +++ b/modules/es/models/es.SurfaceModel.js @@ -118,12 +118,12 @@ es.SurfaceModel.prototype.transact = function( transaction, combine ) { * @param {Integer} Number of document-changing states to reverse */ es.SurfaceModel.prototype.undo = function( transactionsToUndo ) { - /** - * Undo a state. - * @return {Boolean} whether visible change was undone. - */ - function undoState( state ) { + + while ( transactionsToUndo ) { var hadTransaction = false; + + var state = this.currentState; + var i = state.length - 1; while ( i-- ) { if ( state[i] instanceof es.TransactionModel ) { @@ -132,11 +132,7 @@ es.SurfaceModel.prototype.undo = function( transactionsToUndo ) { } } this.emit( 'undo', state ); - return hadTransaction; - } - while ( transactionsToUndo ) { - var hadTransaction = undoState( this.currentState ); if ( hadTransaction ) { transactionsToUndo--; }