From: Roan Kattouw Date: Fri, 3 Jun 2011 10:08:06 +0000 (+0000) Subject: (bug 29105) Splitlines completely messes up selection of inserted text. This is not... X-Git-Tag: 1.31.0-rc.0~29744 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=35dbdb618f861a3b2acaf971a90c3c31d8e06879;p=lhc%2Fweb%2Fwiklou.git (bug 29105) Splitlines completely messes up selection of inserted text. This is not a problem in practice (WikiEditor doesn't have multiline insertions with splitlines enabled since r89402), but just in case it ever becomes a problem I'm disabling selection of inserted text altogether when splitlines is enabled; instead, the cursor will be moved to the end of the inserted text. --- diff --git a/resources/jquery/jquery.textSelection.js b/resources/jquery/jquery.textSelection.js index 1af2b72407..49286d713e 100644 --- a/resources/jquery/jquery.textSelection.js +++ b/resources/jquery/jquery.textSelection.js @@ -128,12 +128,11 @@ encapsulateSelection: function( options ) { selText = selText.replace( /\r?\n/g, "\r\n" ); post = post.replace( /\r?\n/g, "\r\n" ); } - if ( isSample && options.selectPeri ) { + if ( isSample && options.selectPeri && !options.splitlines ) { this.selectionStart = startPos + pre.length; this.selectionEnd = startPos + pre.length + selText.length; } else { - this.selectionStart = startPos + pre.length + selText.length + - post.length; + this.selectionStart = startPos + insertText.length; this.selectionEnd = this.selectionStart; } } else if ( document.selection && document.selection.createRange ) { @@ -413,7 +412,7 @@ scrollToCaretPosition: function( options ) { 'post': '', // Text to insert after the cursor/selection 'ownline': false, // Put the inserted text on a line of its own 'replace': false, // If there is a selection, replace it with peri instead of leaving it alone - 'selectPeri': true, // Select the peri text if it was inserted (but not if there was a selection and replace==false) + 'selectPeri': true, // Select the peri text if it was inserted (but not if there was a selection and replace==false, or if splitlines==true) 'splitlines': false // If multiple lines are selected, encapsulate each line individually }, options ); break;