@@ -18,7 +18,6 @@ import upArrow from '../images/up-arrow.svg?byContent';
1818import exitIcon from '../images/exit.svg?byContent' ;
1919
2020function searchOverlay ( query , caseInsensitive ) {
21- // if the query is a string, we need to convert it into a regular expression
2221 if ( typeof query == 'string' ) {
2322 query = new RegExp (
2423 query . replace ( / [ \- \[ \] \/ \{ \} \( \) \* \+ \? \. \\ \^ \$ \| ] / g, '\\$&' ) ,
@@ -44,7 +43,6 @@ function searchOverlay(query, caseInsensitive) {
4443 } ;
4544}
4645
47- // SearchState is a constructor function that initializes an object to keep track of search-related settings
4846function SearchState ( ) {
4947 this . posFrom = this . posTo = this . lastQuery = this . query = null ;
5048 this . overlay = null ;
@@ -98,7 +96,6 @@ function watchFileChanges(cm, searchState, searchField) {
9896
9997 setupObserver ( ) ;
10098
101- // continuously check for the dialog's existence (every 500ms)
10299 setInterval ( ( ) => {
103100 var searchDialog = document . querySelector ( '.CodeMirror-dialog' ) ;
104101 if ( ! searchDialog && observer ) {
@@ -140,11 +137,9 @@ function persistentDialog(cm, text, deflt, onEnter, replaceOpened, onKeyDown) {
140137
141138 watchFileChanges ( cm , getSearchState ( cm ) , searchField ) ;
142139
143- // this runs when the user types in the search box
144140 CodeMirror . on ( searchField , 'keyup' , function ( e ) {
145141 state . replaceStarted = false ;
146142 if ( e . keyCode !== 13 && searchField . value . length > 1 ) {
147- // not enter and more than 1 character to search
148143 startSearch ( cm , getSearchState ( cm ) , searchField . value ) ;
149144 } else if ( searchField . value . length < 1 ) {
150145 cm . display . wrapper . querySelector (
@@ -376,7 +371,6 @@ function parseString(string) {
376371function parseQuery ( query , state ) {
377372 var emptyQuery = 'x^' ; // matches nothing
378373 if ( query === '' ) {
379- // empty string matches nothing
380374 query = emptyQuery ;
381375 } else {
382376 if ( state . regexp === false ) {
@@ -409,7 +403,7 @@ function startSearch(cm, state, query) {
409403 ?. innerText ;
410404
411405 if ( state . lastFileName !== currentFileName ) {
412- state . lastFileName = currentFileName ; // update stored filename
406+ state . lastFileName = currentFileName ;
413407 state . queryText = null ;
414408 state . lastQuery = null ;
415409 state . query = null ;
@@ -440,16 +434,14 @@ function startSearch(cm, state, query) {
440434 ) ;
441435 }
442436
443- // Updating the UI everytime the search input changes
444437 var cursor = getSearchCursor ( cm , state . query ) ;
445438 cursor . findNext ( ) ;
446439 var num_match = cm . state . search . annotate . matches . length ;
447- // no matches found
448440 if ( num_match == 0 ) {
449441 cm . display . wrapper . querySelector (
450442 '.CodeMirror-search-results'
451443 ) . innerText = i18n . t ( 'CodemirrorFindAndReplace.NoResults' ) ;
452- cm . removeOverlay ( state . overlay , state . caseInsensitive ) ; // removes any existing search highlights
444+ cm . removeOverlay ( state . overlay , state . caseInsensitive ) ;
453445 } else {
454446 var next =
455447 cm . state . search . annotate . matches . findIndex ( ( s ) => {
0 commit comments