jenkins-bot has submitted this change and it was merged.

Change subject: ce.Surface: only change selection during CleanupUnicorns if 
it's in the document
......................................................................


ce.Surface: only change selection during CleanupUnicorns if it's in the document

Bug: T140978
Change-Id: I2e07087cdb258edf0f06502cdf0aa395def11c26
---
M src/ce/ve.ce.Surface.js
1 file changed, 11 insertions(+), 5 deletions(-)

Approvals:
  Divec: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index c268f3a..41aec9b 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -1471,7 +1471,7 @@
  * @return {boolean} Whether unicorns have been destroyed
  */
 ve.ce.Surface.prototype.cleanupUnicorns = function ( fixupCursor ) {
-       var preUnicorn, postUnicorn, range, node, fixup;
+       var preUnicorn, postUnicorn, range, node, fixup, veRange;
        if ( !this.unicorningNode || !this.unicorningNode.unicorns ) {
                return false;
        }
@@ -1518,10 +1518,16 @@
        // Apply the DOM selection to the model
        this.incRenderLock();
        try {
-               this.changeModel( null, new ve.dm.LinearSelection(
-                       this.model.getDocument(),
-                       ve.ce.veRangeFromSelection( this.nativeSelection )
-               ) );
+               veRange = ve.ce.veRangeFromSelection( this.nativeSelection );
+               if ( veRange ) {
+                       // The most likely reason for this condition to 
not-pass is if we
+                       // try to cleanup unicorns while the native selection 
is outside
+                       // the model momentarily, as sometimes happens during 
paste.
+                       this.changeModel( null, new ve.dm.LinearSelection(
+                               this.model.getDocument(),
+                               veRange
+                       ) );
+               }
                if ( fixupCursor ) {
                        this.moveModelCursor( fixup );
                }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2e07087cdb258edf0f06502cdf0aa395def11c26
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
Gerrit-Reviewer: DLynch <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to