(cm, prev, query, repeat)
| 4417 | }, 50); |
| 4418 | } |
| 4419 | function findNext(cm, prev, query, repeat) { |
| 4420 | if (repeat === undefined) { repeat = 1; } |
| 4421 | return cm.operation(function() { |
| 4422 | var pos = cm.getCursor(); |
| 4423 | var cursor = cm.getSearchCursor(query, pos); |
| 4424 | for (var i = 0; i < repeat; i++) { |
| 4425 | var found = cursor.find(prev); |
| 4426 | if (i == 0 && found && cursorEqual(cursor.from(), pos)) { found = cursor.find(prev); } |
| 4427 | if (!found) { |
| 4428 | // SearchCursor may have returned null because it hit EOF, wrap |
| 4429 | // around and try again. |
| 4430 | cursor = cm.getSearchCursor(query, |
| 4431 | (prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) ); |
| 4432 | if (!cursor.find(prev)) { |
| 4433 | return; |
| 4434 | } |
| 4435 | } |
| 4436 | } |
| 4437 | return cursor.from(); |
| 4438 | }); |
| 4439 | } |
| 4440 | /** |
| 4441 | * Pretty much the same as `findNext`, except for the following differences: |
| 4442 | * |
no test coverage detected