| 13228 | } |
| 13229 | } |
| 13230 | function findNext(cm, prev, query, repeat) { |
| 13231 | if (repeat === undefined) { repeat = 1; } |
| 13232 | return cm.operation(function() { |
| 13233 | var pos = cm.getCursor(); |
| 13234 | var cursor = cm.getSearchCursor(query, pos); |
| 13235 | for (var i = 0; i < repeat; i++) { |
| 13236 | var found = cursor.find(prev); |
| 13237 | if (i == 0 && found && cursorEqual(cursor.from(), pos)) { found = cursor.find(prev); } |
| 13238 | if (!found) { |
| 13239 | // SearchCursor may have returned null because it hit EOF, wrap |
| 13240 | // around and try again. |
| 13241 | cursor = cm.getSearchCursor(query, |
| 13242 | (prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) ); |
| 13243 | if (!cursor.find(prev)) { |
| 13244 | return; |
| 13245 | } |
| 13246 | } |
| 13247 | } |
| 13248 | return cursor.from(); |
| 13249 | }); |
| 13250 | } |
| 13251 | function clearSearchHighlight(cm) { |
| 13252 | var state = getSearchState(cm); |
| 13253 | cm.removeOverlay(getSearchState(cm).getOverlay()); |