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 1616} ) ( function ( CodeMirror ) {
1717 "use strict" ;
1818 function searchOverlay ( query , caseInsensitive ) {
19- var startChar ;
20- if ( typeof query == "string" ) {
21- startChar = query . charAt ( 0 ) ;
22- query = new RegExp ( "^" + query . replace ( / [ \- \[ \] \/ \{ \} \( \) \* \+ \? \. \\ \^ \$ \| ] / g, "\\$&" ) ,
23- caseInsensitive ? "i" : "" ) ;
24- } else {
25- query = new RegExp ( "^(?:" + query . source + ")" , query . ignoreCase ? "i" : "" ) ;
26- }
19+ if ( typeof query == "string" )
20+ query = new RegExp ( query . replace ( / [ \- \[ \] \/ \{ \} \( \) \* \+ \? \. \\ \^ \$ \| ] / g, "\\$&" ) , caseInsensitive ? "gi" : "g" ) ;
21+ else if ( ! query . global )
22+ query = new RegExp ( query . source , query . ignoreCase ? "gi" : "g" ) ;
23+
2724 return { token : function ( stream ) {
28- if ( stream . match ( query ) ) return "searching" ;
29- while ( ! stream . eol ( ) ) {
30- stream . next ( ) ;
31- if ( startChar && ! caseInsensitive )
32- stream . skipTo ( startChar ) || stream . skipToEnd ( ) ;
33- if ( stream . match ( query , false ) ) break ;
25+ query . lastIndex = stream . pos ;
26+ var match = query . exec ( stream . string ) ;
27+ if ( match && match . index == stream . pos ) {
28+ stream . pos += match [ 0 ] . length ;
29+ return "searching" ;
30+ } else if ( match ) {
31+ stream . pos = match . index ;
32+ } else {
33+ stream . skipToEnd ( ) ;
3434 }
3535 } } ;
3636 }
You can’t perform that action at this time.
0 commit comments