Esanders has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387929 )

Change subject: Wait for selection reset when setting selection in NWE
......................................................................

Wait for selection reset when setting selection in NWE

Change-Id: I05fc5678a6945c13c7f390cb30e7fac6efb2767f
---
M modules/ext.linter.edit.js
1 file changed, 9 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/29/387929/1

diff --git a/modules/ext.linter.edit.js b/modules/ext.linter.edit.js
index fa13f98..3915fd5 100644
--- a/modules/ext.linter.edit.js
+++ b/modules/ext.linter.edit.js
@@ -22,13 +22,16 @@
                        // Register NWE code should it be loaded
                        // TODO: We should somehow force source mode if VE is 
opened
                        mw.hook( 've.activationComplete' ).add( function () {
-                               var range,
-                                       surface = ve.init.target.getSurface();
+                               // Selection is reset on a setTimeout after 
activation, so wait for that.
+                               setTimeout( function () {
+                                       var range,
+                                               surface = 
ve.init.target.getSurface();
 
-                               if ( surface.getMode() === 'source' ) {
-                                       range = new ve.Range( fixOffset( 
surface, location[ 0 ] ), fixOffset( surface, location[ 1 ] ) );
-                                       surface.getModel().setLinearSelection( 
range );
-                               }
+                                       if ( surface.getMode() === 'source' ) {
+                                               range = new ve.Range( 
fixOffset( surface, location[ 0 ] ), fixOffset( surface, location[ 1 ] ) );
+                                               
surface.getModel().setLinearSelection( range );
+                                       }
+                               } );
                        } );
                }
        } );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I05fc5678a6945c13c7f390cb30e7fac6efb2767f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to