@@ -1225,10 +1225,41 @@ var CodeMirror = (function() {
12251225 changes . push ( { from : 0 , to : doc . size } ) ;
12261226 }
12271227
1228+ function TextMarker ( ) { this . set = [ ] ; }
1229+ TextMarker . prototype . clear = operation ( function ( ) {
1230+ for ( var i = 0 , e = this . set . length ; i < e ; ++ i ) {
1231+ var mk = this . set [ i ] . marked ;
1232+ if ( ! mk ) continue ;
1233+ for ( var j = 0 ; j < mk . length ; ++ j )
1234+ if ( mk [ j ] . set == this . set ) mk . splice ( j -- , 1 ) ;
1235+ }
1236+ // We don't know the exact lines that changed. Refreshing is
1237+ // cheaper than finding them.
1238+ changes . push ( { from : 0 , to : doc . size } ) ;
1239+ } ) ;
1240+ TextMarker . prototype . find = function ( ) {
1241+ var from , to ;
1242+ for ( var i = 0 , e = this . set . length ; i < e ; ++ i ) {
1243+ var line = this . set [ i ] , mk = line . marked ;
1244+ for ( var j = 0 ; j < mk . length ; ++ j ) {
1245+ var mark = mk [ j ] ;
1246+ if ( mark . set == this . set ) {
1247+ if ( mark . from != null || mark . to != null ) {
1248+ var found = lineNo ( line ) ;
1249+ if ( found != null ) {
1250+ if ( mark . from != null ) from = { line : found , ch : mark . from } ;
1251+ if ( mark . to != null ) to = { line : found , ch : mark . to } ;
1252+ }
1253+ }
1254+ }
1255+ }
1256+ }
1257+ return { from : from , to : to } ;
1258+ } ;
1259+
12281260 function markText ( from , to , className ) {
12291261 from = clipPos ( from ) ; to = clipPos ( to ) ;
12301262 var tm = new TextMarker ( ) ;
1231- tm . clear = operation ( tm . clear ) ;
12321263 function add ( line , from , to , className ) {
12331264 mark = getLine ( line ) . addMark ( new MarkedText ( from , to , className , tm . set ) ) ;
12341265 }
@@ -1966,38 +1997,6 @@ var CodeMirror = (function() {
19661997 } ;
19671998 CodeMirror . StringStream = StringStream ;
19681999
1969- function TextMarker ( ) { this . set = [ ] ; }
1970- TextMarker . prototype . clear = function ( ) {
1971- for ( var i = 0 , e = this . set . length ; i < e ; ++ i ) {
1972- var mk = this . set [ i ] . marked ;
1973- if ( ! mk ) continue ;
1974- for ( var j = 0 ; j < mk . length ; ++ j )
1975- if ( mk [ j ] . set == this . set ) mk . splice ( j -- , 1 ) ;
1976- }
1977- // We don't know the exact lines that changed. Refreshing is
1978- // cheaper than finding them.
1979- changes . push ( { from : 0 , to : doc . size } ) ;
1980- } ;
1981- TextMarker . prototype . find = function ( ) {
1982- var from , to ;
1983- for ( var i = 0 , e = this . set . length ; i < e ; ++ i ) {
1984- var line = this . set [ i ] , mk = line . marked ;
1985- for ( var j = 0 ; j < mk . length ; ++ j ) {
1986- var mark = mk [ j ] ;
1987- if ( mark . set == this . set ) {
1988- if ( mark . from != null || mark . to != null ) {
1989- var found = lineNo ( line ) ;
1990- if ( found != null ) {
1991- if ( mark . from != null ) from = { line : found , ch : mark . from } ;
1992- if ( mark . to != null ) to = { line : found , ch : mark . to } ;
1993- }
1994- }
1995- }
1996- }
1997- }
1998- return { from : from , to : to } ;
1999- } ;
2000-
20012000 function MarkedText ( from , to , className , set ) {
20022001 this . from = from ; this . to = to ; this . style = className ; this . set = set ;
20032002 }
0 commit comments