| 4359 | return query; |
| 4360 | } |
| 4361 | function searchOverlay(query) { |
| 4362 | if (query.source.charAt(0) == '^') { |
| 4363 | var matchSol = true; |
| 4364 | } |
| 4365 | return { |
| 4366 | token: function(stream) { |
| 4367 | if (matchSol && !stream.sol()) { |
| 4368 | stream.skipToEnd(); |
| 4369 | return; |
| 4370 | } |
| 4371 | var match = stream.match(query, false); |
| 4372 | if (match) { |
| 4373 | if (match[0].length == 0) { |
| 4374 | // Matched empty string, skip to next. |
| 4375 | stream.next(); |
| 4376 | return 'searching'; |
| 4377 | } |
| 4378 | if (!stream.sol()) { |
| 4379 | // Backtrack 1 to match \b |
| 4380 | stream.backUp(1); |
| 4381 | if (!query.exec(stream.next() + match[0])) { |
| 4382 | stream.next(); |
| 4383 | return null; |
| 4384 | } |
| 4385 | } |
| 4386 | stream.match(query); |
| 4387 | return 'searching'; |
| 4388 | } |
| 4389 | while (!stream.eol()) { |
| 4390 | stream.next(); |
| 4391 | if (stream.match(query, false)) break; |
| 4392 | } |
| 4393 | }, |
| 4394 | query: query |
| 4395 | }; |
| 4396 | } |
| 4397 | var highlightTimeout = 0; |
| 4398 | function highlightSearchMatches(cm, query) { |
| 4399 | clearTimeout(highlightTimeout); |