jenkins-bot has submitted this change and it was merged.
Change subject: AceEditorWidget: Preserve selection on setValue
......................................................................
AceEditorWidget: Preserve selection on setValue
Also avoid calling setValue when the value hasn't changed
so as not to pollute the undo stack.
Change-Id: I07fc5db0480a8583b361d472723f863ca90046f7
---
M modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
1 file changed, 6 insertions(+), 2 deletions(-)
Approvals:
Jforrester: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
b/modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
index 86797c4..4a73121 100644
--- a/modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
+++ b/modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js
@@ -96,8 +96,12 @@
ve.ui.MWAceEditorWidget.prototype.setValue = function ( value ) {
var widget = this;
this.loadingPromise.done( function () {
- widget.editor.setValue( value );
- widget.editor.selection.moveTo( 0, 0 );
+ var selectionState;
+ if ( value !== widget.editor.getValue() ) {
+ selectionState =
widget.editor.session.selection.toJSON();
+ widget.editor.setValue( value );
+ widget.editor.session.selection.fromJSON(
selectionState );
+ }
} ).fail( function () {
ve.ui.MWAceEditorWidget.super.prototype.setValue.call( widget,
value );
} );
--
To view, visit https://gerrit.wikimedia.org/r/250031
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I07fc5db0480a8583b361d472723f863ca90046f7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits