@@ -280,7 +280,6 @@ export default function(CodeMirror) {
280
280
function doFindAndReplace ( cm , rev , persistent , immediate , ignoreQuery , replaceOpened ) {
281
281
var state = getSearchState ( cm ) ;
282
282
if ( ! ignoreQuery && state . query ) {
283
- console . log ( 'Here' ) ;
284
283
return findNext ( cm , rev ) ;
285
284
}
286
285
var q = cm . getSelection ( ) || state . lastQuery ;
@@ -331,57 +330,6 @@ export default function(CodeMirror) {
331
330
}
332
331
}
333
332
334
- function doSearch ( cm , rev , persistent , immediate , ignoreQuery ) {
335
- var state = getSearchState ( cm ) ;
336
- if ( ! ignoreQuery && state . query ) return findNext ( cm , rev ) ;
337
- var q = cm . getSelection ( ) || state . lastQuery ;
338
- if ( persistent && cm . openDialog ) {
339
- var hiding = null
340
- var searchNext = function ( query , event ) {
341
- CodeMirror . e_stop ( event ) ;
342
- if ( ! query ) return ;
343
- if ( query != state . queryText ) {
344
- startSearch ( cm , state , query ) ;
345
- state . posFrom = state . posTo = cm . getCursor ( ) ;
346
- }
347
- if ( hiding ) hiding . style . opacity = 1
348
- findNext ( cm , event . shiftKey , function ( _ , to ) {
349
- var dialog
350
- if ( to . line < 3 && document . querySelector &&
351
- ( dialog = cm . display . wrapper . querySelector ( ".CodeMirror-dialog" ) ) &&
352
- dialog . getBoundingClientRect ( ) . bottom - 4 > cm . cursorCoords ( to , "window" ) . top )
353
- ( hiding = dialog ) . style . opacity = .4
354
- } )
355
- } ;
356
- persistentDialog ( cm , queryDialog , q , searchNext , function ( event , query ) {
357
- var keyName = CodeMirror . keyName ( event )
358
- var cmd = CodeMirror . keyMap [ cm . getOption ( "keyMap" ) ] [ keyName ]
359
- if ( ! cmd ) cmd = cm . getOption ( 'extraKeys' ) [ keyName ]
360
- if ( cmd == "findNext" || cmd == "findPrev" ||
361
- cmd == "findPersistentNext" || cmd == "findPersistentPrev" ) {
362
- CodeMirror . e_stop ( event ) ;
363
- startSearch ( cm , getSearchState ( cm ) , query ) ;
364
- cm . execCommand ( cmd ) ;
365
- } else if ( cmd == "find" || cmd == "findPersistent" ) {
366
- CodeMirror . e_stop ( event ) ;
367
- searchNext ( query , event ) ;
368
- }
369
- } ) ;
370
- if ( immediate && q ) {
371
- startSearch ( cm , state , q ) ;
372
- findNext ( cm , rev ) ;
373
- }
374
- } else {
375
- dialog ( cm , queryDialog , "Search for:" , q , function ( query ) {
376
- if ( query && ! state . query ) cm . operation ( function ( ) {
377
- startSearch ( cm , state , query ) ;
378
- state . posFrom = state . posTo = cm . getCursor ( ) ;
379
- findNext ( cm , rev ) ;
380
- } ) ;
381
- } ) ;
382
- }
383
- }
384
-
385
333
function findNext ( cm , rev , callback ) { cm . operation ( function ( ) {
386
334
var state = getSearchState ( cm ) ;
387
335
var cursor = getSearchCursor ( cm , state . query , rev ? state . posFrom : state . posTo ) ;
@@ -433,8 +381,7 @@ export default function(CodeMirror) {
433
381
prevDialog . parentNode . removeChild ( prevDialog ) ;
434
382
cm . focus ( ) ;
435
383
if ( cm . getOption ( "readOnly" ) ) return ;
436
- var query = cm . getSelection ( ) || state . lastQuery ;
437
-
384
+ var query = parseQuery ( queryText , state ) ;
438
385
if ( all ) {
439
386
replaceAll ( cm , query , withText )
440
387
} else {
@@ -542,8 +489,8 @@ export default function(CodeMirror) {
542
489
CodeMirror . commands . findPersistent = function ( cm ) { doFindAndReplace ( cm , false , true , false , true , false ) ; } ;
543
490
CodeMirror . commands . findPersistentNext = function ( cm ) { doFindAndReplace ( cm , false , true , false , true , false ) ; } ;
544
491
CodeMirror . commands . findPersistentPrev = function ( cm ) { doFindAndReplace ( cm , false , true , false , true , false ) ; } ;
545
- CodeMirror . commands . findNext = doSearch ;
546
- CodeMirror . commands . findPrev = function ( cm ) { doSearch ( cm , true ) ; } ;
492
+ CodeMirror . commands . findNext = doFindAndReplace ;
493
+ CodeMirror . commands . findPrev = function ( cm ) { doFindAndReplace ( cm , true ) ; } ;
547
494
CodeMirror . commands . clearSearch = clearSearch ;
548
495
CodeMirror . commands . replace = function ( cm ) { doFindAndReplace ( cm , false , true , false , true , true ) ; } ;
549
496
CodeMirror . commands . replaceAll = function ( cm ) { doFindAndReplace ( cm , false , true , false , true , true ) ; } ;
0 commit comments