(cm, prev, repeat)
| 2104 | } |
| 2105 | } |
| 2106 | function findNext(cm, prev, repeat) { |
| 2107 | return cm.operation(function() { |
| 2108 | var state = getSearchState(cm); |
| 2109 | var query = state.getQuery(); |
| 2110 | if (!query) { |
| 2111 | return; |
| 2112 | } |
| 2113 | if (!state.getMarked()) { |
| 2114 | highlightSearchMatches(cm, query); |
| 2115 | } |
| 2116 | var pos = cm.getCursor(); |
| 2117 | // If search is initiated with ? instead of /, negate direction. |
| 2118 | prev = (state.isReversed()) ? !prev : prev; |
| 2119 | if (!prev) { |
| 2120 | pos.ch += 1; |
| 2121 | } |
| 2122 | var cursor = cm.getSearchCursor(query, pos); |
| 2123 | for (var i = 0; i < repeat; i++) { |
| 2124 | if (!cursor.find(prev)) { |
| 2125 | // SearchCursor may have returned null because it hit EOF, wrap |
| 2126 | // around and try again. |
| 2127 | cursor = cm.getSearchCursor(query, |
| 2128 | (prev) ? { line: cm.lastLine() } : {line: cm.firstLine(), ch: 0} ); |
| 2129 | if (!cursor.find(prev)) { |
| 2130 | return; |
| 2131 | } |
| 2132 | } |
| 2133 | } |
| 2134 | return cursor.from(); |
| 2135 | });} |
| 2136 | function clearSearchHighlight(cm) { |
| 2137 | if (cm.addOverlay) { |
| 2138 | cm.removeOverlay(getSearchState(cm).getOverlay()); |
no test coverage detected