@@ -58,7 +58,7 @@ define(function (require, exports, module) {
5858 return cm . getSearchCursor ( query , pos , typeof query === "string" && query === query . toLowerCase ( ) ) ;
5959 }
6060
61- function getDialogTextField ( modalBar ) {
61+ function getDialogTextField ( ) {
6262 return $ ( "input[type='text']" , modalBar . getRoot ( ) ) ;
6363 }
6464
@@ -156,7 +156,7 @@ define(function (require, exports, module) {
156156
157157 // Called each time the search query changes while being typed. Jumps to the first matching
158158 // result, starting from the original cursor position
159- function findFirst ( query , modalBar ) {
159+ function findFirst ( query ) {
160160 cm . operation ( function ( ) {
161161 if ( ! query ) {
162162 return ;
@@ -179,14 +179,16 @@ define(function (require, exports, module) {
179179 state . posFrom = state . posTo = searchStartPos ;
180180 var foundAny = findNext ( cm , rev ) ;
181181
182- getDialogTextField ( modalBar ) . toggleClass ( "no-results" , ! foundAny ) ;
182+ if ( modalBar ) {
183+ getDialogTextField ( ) . toggleClass ( "no-results" , ! foundAny ) ;
184+ }
183185 } ) ;
184186 }
185187
186188 if ( modalBar ) {
187189 // The modalBar was already up. When creating the new modalBar, copy the
188190 // current query instead of using the passed-in selected text.
189- initialQuery = getDialogTextField ( modalBar ) . attr ( "value" ) ;
191+ initialQuery = getDialogTextField ( ) . attr ( "value" ) ;
190192 }
191193
192194 createModalBar ( queryDialog , true ) ;
@@ -197,21 +199,21 @@ define(function (require, exports, module) {
197199 // next occurrence. In this case we want to start searching
198200 // *after* the current selection so we find the next occurrence.
199201 searchStartPos = cm . getCursor ( false ) ;
200- findFirst ( query , modalBar ) ;
202+ findFirst ( query ) ;
201203 }
202204 } ) ;
203205
204- var $input = getDialogTextField ( modalBar ) ;
206+ var $input = getDialogTextField ( ) ;
205207 $input . on ( "input" , function ( ) {
206- findFirst ( $input . attr ( "value" ) , modalBar ) ;
208+ findFirst ( $input . attr ( "value" ) ) ;
207209 } ) ;
208210
209211 // Prepopulate the search field with the current selection, if any.
210212 if ( initialQuery !== undefined ) {
211213 $input
212214 . attr ( "value" , initialQuery )
213215 . get ( 0 ) . select ( ) ;
214- findFirst ( initialQuery , modalBar ) ;
216+ findFirst ( initialQuery ) ;
215217 // Clear the "findNextCalled" flag here so we have a clean start
216218 state . findNextCalled = false ;
217219 }
@@ -292,7 +294,7 @@ define(function (require, exports, module) {
292294 } ) ;
293295
294296 // Prepopulate the replace field with the current selection, if any
295- getDialogTextField ( modalBar )
297+ getDialogTextField ( )
296298 . attr ( "value" , cm . getSelection ( ) )
297299 . get ( 0 ) . select ( ) ;
298300 }
0 commit comments