@@ -163,6 +163,7 @@ define(function (require, exports, module) {
163163 }
164164 }
165165
166+ console . assert ( state . matchIndex !== - 1 ) ;
166167 if ( state . matchIndex !== - 1 ) {
167168 // Convert to 1-based by adding one before showing the index.
168169 findBar . showFindCount ( StringUtils . format ( Strings . FIND_MATCH_INDEX ,
@@ -404,6 +405,7 @@ define(function (require, exports, module) {
404405 function clearCurrentMatchHighlight ( cm , state ) {
405406 if ( state . markedCurrent ) {
406407 state . markedCurrent . clear ( ) ;
408+ ScrollTrackMarkers . markCurrent ( - 1 ) ;
407409 }
408410 }
409411
@@ -426,13 +428,28 @@ define(function (require, exports, module) {
426428
427429 var nextMatch = _getNextMatch ( editor , searchBackwards , pos ) ;
428430 if ( nextMatch ) {
429- _updateFindBarWithMatchInfo ( getSearchState ( editor . _codeMirror ) ,
430- { from : nextMatch . start , to : nextMatch . end } , searchBackwards ) ;
431+ // Update match index indicators - only possible if we have resultSet saved (missing if FIND_MAX_FILE_SIZE threshold hit)
432+ if ( state . resultSet . length ) {
433+ _updateFindBarWithMatchInfo ( state ,
434+ { from : nextMatch . start , to : nextMatch . end } , searchBackwards ) ;
435+ // Update current-tickmark indicator - only if highlighting enabled (disabled if FIND_HIGHLIGHT_MAX threshold hit)
436+ if ( state . marked . length ) {
437+ ScrollTrackMarkers . markCurrent ( state . matchIndex ) ; // _updateFindBarWithMatchInfo() has updated this index
438+ }
439+ }
440+
431441 _selectAndScrollTo ( editor , [ nextMatch ] , true , preferNoScroll ) ;
432- state . markedCurrent = cm . markText ( nextMatch . start , nextMatch . end ,
433- { className : "searching-current-match" , startStyle : "searching-first" , endStyle : "searching-last" } ) ;
442+
443+ // Only mark text with "current match" highlight if search bar still open
444+ if ( findBar && ! findBar . isClosed ( ) ) {
445+ // If highlighting disabled, apply both match AND current-match styles for correct appearance
446+ var curentMatchClassName = state . marked . length ? "searching-current-match" : "CodeMirror-searching searching-current-match" ;
447+ state . markedCurrent = cm . markText ( nextMatch . start , nextMatch . end ,
448+ { className : curentMatchClassName , startStyle : "searching-first" , endStyle : "searching-last" } ) ;
449+ }
434450 } else {
435451 cm . setCursor ( editor . getCursorPos ( ) ) ; // collapses selection, keeping cursor in place to avoid scrolling
452+ // (nothing more to do: previous highlights already cleared above)
436453 }
437454 } ) ;
438455 }
0 commit comments