File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change 88
99( function ( ) {
1010 function searchOverlay ( query , caseInsensitive ) {
11- var startChar ;
12- if ( typeof query == "string" ) {
13- startChar = query . charAt ( 0 ) ;
14- query = new RegExp ( "^" + query . replace ( / [ \- \[ \] \/ \{ \} \( \) \* \+ \? \. \\ \^ \$ \| ] / g, "\\$&" ) ,
15- caseInsensitive ? "i" : "" ) ;
16- } else {
17- query = new RegExp ( "^(?:" + query . source + ")" , query . ignoreCase ? "i" : "" ) ;
18- }
11+ if ( typeof query == "string" )
12+ query = new RegExp ( query . replace ( / [ \- \[ \] \/ \{ \} \( \) \* \+ \? \. \\ \^ \$ \| ] / g, "\\$&" ) , caseInsensitive ? "gi" : "g" ) ;
13+ else if ( ! query . global )
14+ query = new RegExp ( query . source , query . ignoreCase ? "gi" : "g" ) ;
15+
1916 return { token : function ( stream ) {
20- if ( stream . match ( query ) ) return "searching" ;
21- while ( ! stream . eol ( ) ) {
22- stream . next ( ) ;
23- if ( startChar && ! caseInsensitive )
24- stream . skipTo ( startChar ) || stream . skipToEnd ( ) ;
25- if ( stream . match ( query , false ) ) break ;
17+ query . lastIndex = stream . pos ;
18+ var match = query . exec ( stream . string ) ;
19+ if ( match && match . index == stream . pos ) {
20+ stream . pos += match [ 0 ] . length ;
21+ return "searching" ;
22+ } else if ( match ) {
23+ stream . pos = match . index ;
24+ } else {
25+ stream . skipToEnd ( ) ;
2626 }
2727 } } ;
2828 }
You can’t perform that action at this time.
0 commit comments