@@ -18,7 +18,6 @@ import upArrow from '../images/up-arrow.svg?byContent';
18
18
import exitIcon from '../images/exit.svg?byContent' ;
19
19
20
20
function searchOverlay ( query , caseInsensitive ) {
21
- // if the query is a string, we need to convert it into a regular expression
22
21
if ( typeof query == 'string' ) {
23
22
query = new RegExp (
24
23
query . replace ( / [ \- \[ \] \/ \{ \} \( \) \* \+ \? \. \\ \^ \$ \| ] / g, '\\$&' ) ,
@@ -44,7 +43,6 @@ function searchOverlay(query, caseInsensitive) {
44
43
} ;
45
44
}
46
45
47
- // SearchState is a constructor function that initializes an object to keep track of search-related settings
48
46
function SearchState ( ) {
49
47
this . posFrom = this . posTo = this . lastQuery = this . query = null ;
50
48
this . overlay = null ;
@@ -98,7 +96,6 @@ function watchFileChanges(cm, searchState, searchField) {
98
96
99
97
setupObserver ( ) ;
100
98
101
- // continuously check for the dialog's existence (every 500ms)
102
99
setInterval ( ( ) => {
103
100
var searchDialog = document . querySelector ( '.CodeMirror-dialog' ) ;
104
101
if ( ! searchDialog && observer ) {
@@ -140,11 +137,9 @@ function persistentDialog(cm, text, deflt, onEnter, replaceOpened, onKeyDown) {
140
137
141
138
watchFileChanges ( cm , getSearchState ( cm ) , searchField ) ;
142
139
143
- // this runs when the user types in the search box
144
140
CodeMirror . on ( searchField , 'keyup' , function ( e ) {
145
141
state . replaceStarted = false ;
146
142
if ( e . keyCode !== 13 && searchField . value . length > 1 ) {
147
- // not enter and more than 1 character to search
148
143
startSearch ( cm , getSearchState ( cm ) , searchField . value ) ;
149
144
} else if ( searchField . value . length < 1 ) {
150
145
cm . display . wrapper . querySelector (
@@ -376,7 +371,6 @@ function parseString(string) {
376
371
function parseQuery ( query , state ) {
377
372
var emptyQuery = 'x^' ; // matches nothing
378
373
if ( query === '' ) {
379
- // empty string matches nothing
380
374
query = emptyQuery ;
381
375
} else {
382
376
if ( state . regexp === false ) {
@@ -409,7 +403,7 @@ function startSearch(cm, state, query) {
409
403
?. innerText ;
410
404
411
405
if ( state . lastFileName !== currentFileName ) {
412
- state . lastFileName = currentFileName ; // update stored filename
406
+ state . lastFileName = currentFileName ;
413
407
state . queryText = null ;
414
408
state . lastQuery = null ;
415
409
state . query = null ;
@@ -440,16 +434,14 @@ function startSearch(cm, state, query) {
440
434
) ;
441
435
}
442
436
443
- // Updating the UI everytime the search input changes
444
437
var cursor = getSearchCursor ( cm , state . query ) ;
445
438
cursor . findNext ( ) ;
446
439
var num_match = cm . state . search . annotate . matches . length ;
447
- // no matches found
448
440
if ( num_match == 0 ) {
449
441
cm . display . wrapper . querySelector (
450
442
'.CodeMirror-search-results'
451
443
) . innerText = i18n . t ( 'CodemirrorFindAndReplace.NoResults' ) ;
452
- cm . removeOverlay ( state . overlay , state . caseInsensitive ) ; // removes any existing search highlights
444
+ cm . removeOverlay ( state . overlay , state . caseInsensitive ) ;
453
445
} else {
454
446
var next =
455
447
cm . state . search . annotate . matches . findIndex ( ( s ) => {
0 commit comments