Trevor Parscal has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/61472


Change subject: ve.dm.Surface.truncateUndoStack
......................................................................

ve.dm.Surface.truncateUndoStack

ve.dm.Surface.js
* Allow manual truncation of the undo stack to prevent redoing something that's 
been undone

Change-Id: I17534d6724fc2b325152cb2f665c6816f44232c1
---
M modules/ve/dm/ve.dm.Surface.js
1 file changed, 13 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/72/61472/1

diff --git a/modules/ve/dm/ve.dm.Surface.js b/modules/ve/dm/ve.dm.Surface.js
index 559d4bb..a9a77a2 100644
--- a/modules/ve/dm/ve.dm.Surface.js
+++ b/modules/ve/dm/ve.dm.Surface.js
@@ -252,6 +252,18 @@
 };
 
 /**
+ * Prevent future states from being redone.
+ *
+ * @method
+ * @emits history
+ */
+ve.dm.Surface.prototype.truncateUndoStack = function() {
+       this.bigStack = this.bigStack.slice( 0, this.bigStack.length - 
this.undoIndex );
+       this.undoIndex = 0;
+       this.emit( 'history' );
+};
+
+/**
  * Apply a transactions and selection changes to the document.
  *
  * @method
@@ -284,8 +296,7 @@
                }
                for ( i = 0, len = transactions.length; i < len; i++ ) {
                        if ( !transactions[i].isNoOp() ) {
-                               this.bigStack = this.bigStack.slice( 0, 
this.bigStack.length - this.undoIndex );
-                               this.undoIndex = 0;
+                               this.truncateUndoStack();
                                this.smallStack.push( transactions[i] );
                                this.completeHistory.push( {
                                        'undo': false,

-- 
To view, visit https://gerrit.wikimedia.org/r/61472
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I17534d6724fc2b325152cb2f665c6816f44232c1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to