From 35dbdb618f861a3b2acaf971a90c3c31d8e06879 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 3 Jun 2011 10:08:06 +0000 Subject: [PATCH] (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. --- resources/jquery/jquery.textSelection.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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; -- 2.20.1