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 <p> - * - * @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 <esand...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits