Merge "API: Add license info to API help output"
[lhc/web/wiklou.git] / resources / src / jquery / jquery.textSelection.js
index 632769b..5111930 100644 (file)
                                                        endPos = this.selectionEnd;
                                                        scrollTop = this.scrollTop;
                                                        checkSelectedText();
-                                                       if ( options.selectionStart !== undefined
-                                                                       && endPos - startPos !== options.selectionEnd - options.selectionStart )
-                                                       {
+                                                       if (
+                                                               options.selectionStart !== undefined &&
+                                                               endPos - startPos !== options.selectionEnd - options.selectionStart
+                                                       ) {
                                                                // This means there is a difference in the selection range returned by browser and what we passed.
                                                                // This happens for Chrome in the case of composite characters. Ref bug #30130
                                                                // Set the startPos to the correct position.
                                                                selText = selText.replace( /\r?\n/g, '\r\n' );
                                                                post = post.replace( /\r?\n/g, '\r\n' );
                                                        }
-                                                       if ( isSample && options.selectPeri && !options.splitlines ) {
+                                                       if ( isSample && options.selectPeri && ( !options.splitlines || ( options.splitlines && selText.indexOf( '\n' ) === -1 ) ) ) {
                                                                this.selectionStart = startPos + pre.length;
                                                                this.selectionEnd = startPos + pre.length + selText.length;
                                                        } else {
 
                // Apply defaults
                switch ( command ) {
-                       //case 'getContents': // no params
-                       //case 'setContents': // no params with defaults
-                       //case 'getSelection': // no params
+                       // case 'getContents': // no params
+                       // case 'setContents': // no params with defaults
+                       // case 'getSelection': // no params
                        case 'encapsulateSelection':
                                options = $.extend( {
                                        pre: '', // Text to insert before the cursor/selection