@@ -182,8 +182,16 @@ define(function (require, exports, module) {
182182 }
183183
184184 var queryDialog = Strings . CMD_FIND +
185- ": <input type='text' style='width: 10em'/> <div class='message'><span id='find-counter'></span> " +
186- "<span style='color: #888'>(" + Strings . SEARCH_REGEXP_INFO + ")</span></div><div class='error'></div>" ;
185+ ": <input type='text' style='width: 10em'/>" +
186+ "<div class='navigator'>" +
187+ "<button id='find-prev' class='btn' title='" + Strings . BUTTON_PREV_HINT + "'>" + Strings . BUTTON_PREV + "</button>" +
188+ "<button id='find-next' class='btn' title='" + Strings . BUTTON_NEXT_HINT + "'>" + Strings . BUTTON_NEXT + "</button>" +
189+ "</div>" +
190+ "<div class='message'>" +
191+ "<span id='find-counter'></span> " +
192+ "<span style='color: #888'>(" + Strings . SEARCH_REGEXP_INFO + ")</span>" +
193+ "</div>" +
194+ "<div class='error'></div>" ;
187195
188196 /**
189197 * If no search pending, opens the search dialog. If search is already open, moves to
@@ -203,6 +211,15 @@ define(function (require, exports, module) {
203211 // occurrence.
204212 var searchStartPos = cm . getCursor ( true ) ;
205213
214+ //Helper method to enable next / prev navigation in Find modal bar.
215+ function enableFindNavigator ( show ) {
216+ if ( show ) {
217+ $ ( ".modal-bar .navigator" ) . css ( "display" , "inline-block" ) ;
218+ } else {
219+ $ ( ".modal-bar .navigator" ) . css ( "display" , "none" ) ;
220+ }
221+ }
222+
206223 // Called each time the search query changes while being typed. Jumps to the first matching
207224 // result, starting from the original cursor position
208225 function findFirst ( query ) {
@@ -215,13 +232,17 @@ define(function (require, exports, module) {
215232 if ( ! state . query ) {
216233 // Search field is empty - no results
217234 $ ( "#find-counter" ) . text ( "" ) ;
235+ enableFindNavigator ( false ) ;
218236 cm . setCursor ( searchStartPos ) ;
219237 if ( modalBar ) {
220238 getDialogTextField ( ) . removeClass ( "no-results" ) ;
221239 }
222240 return ;
223241 }
224242
243+ //Flag that controls the navigation controls.
244+ var enableNavigator = false ;
245+
225246 // Highlight all matches
226247 // (Except on huge documents, where this is too expensive)
227248 if ( cm . getValue ( ) . length < 500000 ) {
@@ -243,19 +264,24 @@ define(function (require, exports, module) {
243264 cursor = getSearchCursor ( cm , state . query , { line : cursor . to ( ) . line + 1 , ch : 0 } ) ;
244265 }
245266 }
246-
267+
247268 if ( resultCount === 0 ) {
248269 $ ( "#find-counter" ) . text ( Strings . FIND_NO_RESULTS ) ;
249270 } else if ( resultCount === 1 ) {
250- $ ( "#find-counter" ) . text ( Strings . FIND_RESULT_COUNT_SINGLE ) ;
271+ $ ( "#find-counter" ) . text ( Strings . FIND_RESULT_COUNT_SINGLE ) ;
251272 } else {
252273 $ ( "#find-counter" ) . text ( StringUtils . format ( Strings . FIND_RESULT_COUNT , resultCount ) ) ;
274+ enableNavigator = true ;
253275 }
254276
255277 } else {
256278 $ ( "#find-counter" ) . text ( "" ) ;
279+ enableNavigator = true ;
257280 }
258281
282+ //Enable Next/Prev navigator buttons if necessary
283+ enableFindNavigator ( enableNavigator ) ;
284+
259285 state . posFrom = state . posTo = searchStartPos ;
260286 var foundAny = findNext ( editor , rev ) ;
261287
@@ -291,6 +317,14 @@ define(function (require, exports, module) {
291317 $ ( cm . getWrapperElement ( ) ) . removeClass ( "find-highlighting" ) ;
292318 } ) ;
293319
320+ modalBar . getRoot ( ) . on ( "click" , function ( e ) {
321+ if ( e . target . id === "find-next" ) {
322+ _findNext ( ) ;
323+ } else if ( e . target . id === "find-prev" ) {
324+ _findPrevious ( ) ;
325+ }
326+ } ) ;
327+
294328 var $input = getDialogTextField ( ) ;
295329 $input . on ( "input" , function ( ) {
296330 findFirst ( $input . val ( ) ) ;
0 commit comments