| 13174 | return query; |
| 13175 | } |
| 13176 | function searchOverlay(query) { |
| 13177 | if (query.source.charAt(0) == '^') { |
| 13178 | var matchSol = true; |
| 13179 | } |
| 13180 | return { |
| 13181 | token: function(stream) { |
| 13182 | if (matchSol && !stream.sol()) { |
| 13183 | stream.skipToEnd(); |
| 13184 | return; |
| 13185 | } |
| 13186 | var match = stream.match(query, false); |
| 13187 | if (match) { |
| 13188 | if (match[0].length == 0) { |
| 13189 | // Matched empty string, skip to next. |
| 13190 | stream.next(); |
| 13191 | return 'searching'; |
| 13192 | } |
| 13193 | if (!stream.sol()) { |
| 13194 | // Backtrack 1 to match \b |
| 13195 | stream.backUp(1); |
| 13196 | if (!query.exec(stream.next() + match[0])) { |
| 13197 | stream.next(); |
| 13198 | return null; |
| 13199 | } |
| 13200 | } |
| 13201 | stream.match(query); |
| 13202 | return 'searching'; |
| 13203 | } |
| 13204 | while (!stream.eol()) { |
| 13205 | stream.next(); |
| 13206 | if (stream.match(query, false)) break; |
| 13207 | } |
| 13208 | }, |
| 13209 | query: query |
| 13210 | }; |
| 13211 | } |
| 13212 | function highlightSearchMatches(cm, query) { |
| 13213 | var searchState = getSearchState(cm); |
| 13214 | var overlay = searchState.getOverlay(); |