jenkins-bot has submitted this change and it was merged.
Change subject: Check for past/future state in undo/redo before setting
breakpoint
......................................................................
Check for past/future state in undo/redo before setting breakpoint
This isn't a problem when using the UI buttons as they get disabled
but the command keys can still trigger these methods.
Also fix hasPastState to include check for small stack. This fixes
an existing bug where the undo button doesn't become active until
~1s after the first change is commited (i.e. after the small stack
is committed to the big stack).
Bug: 52113
Change-Id: Idbd34953c805620881a609409290256462af80a5
---
M modules/ve/dm/ve.dm.Surface.js
1 file changed, 4 insertions(+), 4 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/dm/ve.dm.Surface.js b/modules/ve/dm/ve.dm.Surface.js
index 20c6cf7..c8dfc1d 100644
--- a/modules/ve/dm/ve.dm.Surface.js
+++ b/modules/ve/dm/ve.dm.Surface.js
@@ -232,7 +232,7 @@
* @returns {boolean} Has a past state
*/
ve.dm.Surface.prototype.hasPastState = function () {
- return this.bigStack.length - this.undoIndex > 0;
+ return this.bigStack.length - this.undoIndex > 0 ||
!!this.smallStack.length;
};
/**
@@ -442,7 +442,7 @@
* @returns {ve.Range} Selection or null if no further state could be reached
*/
ve.dm.Surface.prototype.undo = function () {
- if ( !this.enabled ) {
+ if ( !this.enabled || !this.hasPastState() ) {
return;
}
var item, i, transaction, selection;
@@ -477,13 +477,13 @@
* @returns {ve.Range} Selection or null if no further state could be reached
*/
ve.dm.Surface.prototype.redo = function () {
- if ( !this.enabled ) {
+ if ( !this.enabled || !this.hasFutureState() ) {
return;
}
var item, i, transaction, selection;
this.breakpoint();
- if ( this.undoIndex > 0 && this.bigStack[this.bigStack.length -
this.undoIndex] ) {
+ if ( this.bigStack[this.bigStack.length - this.undoIndex] ) {
this.emit( 'lock' );
item = this.bigStack[this.bigStack.length - this.undoIndex];
selection = item.selection;
--
To view, visit https://gerrit.wikimedia.org/r/79049
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idbd34953c805620881a609409290256462af80a5
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits