@@ -73,7 +73,7 @@ export default function(CodeMirror) {
73
73
CodeMirror . on ( searchField , "keyup" , function ( e ) {
74
74
if ( e . keyCode !== 13 && searchField . value . length > 1 ) { // not enter and more than 1 character to search
75
75
startSearch ( cm , getSearchState ( cm ) , searchField . value ) ;
76
- } else {
76
+ } else if ( searchField . value . length <= 1 ) {
77
77
cm . display . wrapper . querySelector ( '.CodeMirror-search-results' ) . innerText = '' ;
78
78
}
79
79
} ) ;
@@ -295,10 +295,9 @@ export default function(CodeMirror) {
295
295
if ( state . annotate ) { state . annotate . clear ( ) ; state . annotate = null ; }
296
296
state . annotate = cm . showMatchesOnScrollbar ( state . query , state . caseInsensitive ) ;
297
297
}
298
- var num_match = cm . state . search . annotate . matches . length ;
299
- var text_match =
300
- 'Results: ' + num_match ;
301
- cm . display . wrapper . querySelector ( '.CodeMirror-search-results' ) . innerText = text_match ;
298
+ if ( originalQuery ) {
299
+ return findNext ( cm , false ) ;
300
+ }
302
301
}
303
302
304
303
function doSearch ( cm , rev , persistent , immediate , ignoreQuery ) {
@@ -362,6 +361,11 @@ export default function(CodeMirror) {
362
361
cm . setSelection ( cursor . from ( ) , cursor . to ( ) ) ;
363
362
cm . scrollIntoView ( { from : cursor . from ( ) , to : cursor . to ( ) } , 60 ) ;
364
363
state . posFrom = cursor . from ( ) ; state . posTo = cursor . to ( ) ;
364
+ var num_match = cm . state . search . annotate . matches . length ;
365
+ var next = cm . state . search . annotate . matches
366
+ . findIndex ( s => s . from . ch === cursor . from ( ) . ch && s . from . line === cursor . from ( ) . line ) + 1 ;
367
+ var text_match = next + '/' + num_match ;
368
+ cm . display . wrapper . querySelector ( '.CodeMirror-search-results' ) . innerText = text_match ;
365
369
if ( callback ) callback ( cursor . from ( ) , cursor . to ( ) )
366
370
} ) ; }
367
371
0 commit comments