@@ -2031,8 +2031,9 @@ var CodeMirror = (function() {
20312031
20322032 // See if "".split is the broken IE version, if so, provide an
20332033 // alternative way to split lines.
2034+ var splitLines , selRange , setSelRange ;
20342035 if ( "\n\nb" . split ( / \n / ) . length != 3 )
2035- var splitLines = function ( string ) {
2036+ splitLines = function ( string ) {
20362037 var pos = 0 , nl , result = [ ] ;
20372038 while ( ( nl = string . indexOf ( "\n" , pos ) ) > - 1 ) {
20382039 result . push ( string . slice ( pos , string . charAt ( nl - 1 ) == "\r" ? nl - 1 : nl ) ) ;
@@ -2042,12 +2043,12 @@ var CodeMirror = (function() {
20422043 return result ;
20432044 } ;
20442045 else
2045- var splitLines = function ( string ) { return string . split ( / \r ? \n / ) ; } ;
2046+ splitLines = function ( string ) { return string . split ( / \r ? \n / ) ; } ;
20462047 CodeMirror . splitLines = splitLines ;
20472048
20482049 // Sane model of finding and setting the selection in a textarea
20492050 if ( window . getSelection ) {
2050- var selRange = function ( te ) {
2051+ selRange = function ( te ) {
20512052 try { return { start : te . selectionStart , end : te . selectionEnd } ; }
20522053 catch ( e ) { return null ; }
20532054 } ;
@@ -2058,7 +2059,7 @@ var CodeMirror = (function() {
20582059 // the left. If you press shift-right, the anchor ends up at the
20592060 // front. This is not what CodeMirror wants, so it does a
20602061 // spurious modify() call to get out of limbo.
2061- var setSelRange = function ( te , start , end ) {
2062+ setSelRange = function ( te , start , end ) {
20622063 if ( start == end )
20632064 te . setSelectionRange ( start , end ) ;
20642065 else {
@@ -2067,14 +2068,14 @@ var CodeMirror = (function() {
20672068 }
20682069 } ;
20692070 else
2070- var setSelRange = function ( te , start , end ) {
2071+ setSelRange = function ( te , start , end ) {
20712072 try { te . setSelectionRange ( start , end ) ; }
20722073 catch ( e ) { } // Fails on Firefox when textarea isn't part of the document
20732074 } ;
20742075 }
20752076 // IE model. Don't ask.
20762077 else {
2077- var selRange = function ( te ) {
2078+ selRange = function ( te ) {
20782079 try { var range = te . ownerDocument . selection . createRange ( ) ; }
20792080 catch ( e ) { return null ; }
20802081 if ( ! range || range . parentElement ( ) != te ) return null ;
@@ -2096,7 +2097,7 @@ var CodeMirror = (function() {
20962097 for ( var i = val . indexOf ( "\r" ) ; i > - 1 && i < end ; i = val . indexOf ( "\r" , i + 1 ) , end ++ ) { }
20972098 return { start : start , end : end } ;
20982099 } ;
2099- var setSelRange = function ( te , start , end ) {
2100+ setSelRange = function ( te , start , end ) {
21002101 var range = te . createTextRange ( ) ;
21012102 range . collapse ( true ) ;
21022103 var endrange = range . duplicate ( ) ;
0 commit comments