[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: Use VE's new offset conversion method

2017-11-06 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/387930 )

Change subject: Use VE's new offset conversion method
..


Use VE's new offset conversion method

Change-Id: I64767fccae26522fdce5287c5486c322108c168a
Depends-On: Idc960a37433c5b8d952a677d1529a25b94fac7f7
Depends-On: I1071faeec586fa2b44be810a35f8044800c8f800
---
M modules/ext.linter.edit.js
1 file changed, 1 insertion(+), 13 deletions(-)

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



diff --git a/modules/ext.linter.edit.js b/modules/ext.linter.edit.js
index 3915fd5..63a3c01 100644
--- a/modules/ext.linter.edit.js
+++ b/modules/ext.linter.edit.js
@@ -3,18 +3,6 @@
var location = mw.config.get( 'wgLinterErrorLocation' ),
$textbox = $( '#wpTextbox1' );
 
-   /**
-* Convert the normal offset for one that is usable
-* by VE's DOM that changes newlines into 
-*
-* @param {ve.ui.Surface} surface
-* @param {int} offset
-* @return {int}
-*/
-   function fixOffset( surface, offset ) {
-   return ( surface.getDom().slice( 0, offset ).match( 
/\n/g ) || [] ).length + 1 + offset;
-   }
-
if ( location ) {
if ( $textbox.length ) {
$textbox.focus().textSelection( 'setSelection', 
{ start: location[ 0 ], end: location[ 1 ] } );
@@ -28,7 +16,7 @@
surface = 
ve.init.target.getSurface();
 
if ( surface.getMode() === 'source' ) {
-   range = new ve.Range( 
fixOffset( surface, location[ 0 ] ), fixOffset( surface, location[ 1 ] ) );
+   range = 
surface.getModel().getRangeFromSourceOffsets( location[ 0 ], location[ 1 ] );

surface.getModel().setLinearSelection( range );
}
} );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I64767fccae26522fdce5287c5486c322108c168a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Esanders 
Gerrit-Reviewer: Esanders 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: Use VE's new offset conversion method

2017-11-01 Thread Esanders (Code Review)
Esanders has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387930 )

Change subject: Use VE's new offset conversion method
..

Use VE's new offset conversion method

Change-Id: I64767fccae26522fdce5287c5486c322108c168a
Depends-On: Idc960a37433c5b8d952a677d1529a25b94fac7f7
---
M modules/ext.linter.edit.js
1 file changed, 1 insertion(+), 13 deletions(-)


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

diff --git a/modules/ext.linter.edit.js b/modules/ext.linter.edit.js
index 3915fd5..63a3c01 100644
--- a/modules/ext.linter.edit.js
+++ b/modules/ext.linter.edit.js
@@ -3,18 +3,6 @@
var location = mw.config.get( 'wgLinterErrorLocation' ),
$textbox = $( '#wpTextbox1' );
 
-   /**
-* Convert the normal offset for one that is usable
-* by VE's DOM that changes newlines into 
-*
-* @param {ve.ui.Surface} surface
-* @param {int} offset
-* @return {int}
-*/
-   function fixOffset( surface, offset ) {
-   return ( surface.getDom().slice( 0, offset ).match( 
/\n/g ) || [] ).length + 1 + offset;
-   }
-
if ( location ) {
if ( $textbox.length ) {
$textbox.focus().textSelection( 'setSelection', 
{ start: location[ 0 ], end: location[ 1 ] } );
@@ -28,7 +16,7 @@
surface = 
ve.init.target.getSurface();
 
if ( surface.getMode() === 'source' ) {
-   range = new ve.Range( 
fixOffset( surface, location[ 0 ] ), fixOffset( surface, location[ 1 ] ) );
+   range = 
surface.getModel().getRangeFromSourceOffsets( location[ 0 ], location[ 1 ] );

surface.getModel().setLinearSelection( range );
}
} );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64767fccae26522fdce5287c5486c322108c168a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Esanders 

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