@@ -51,6 +51,7 @@ class SearchBox {
51
51
this . element = div . firstChild ;
52
52
53
53
this . setSession = this . setSession . bind ( this ) ;
54
+ this . $onEditorInput = this . onEditorInput . bind ( this ) ;
54
55
55
56
this . $init ( ) ;
56
57
this . setEditor ( editor ) ;
@@ -72,6 +73,11 @@ class SearchBox {
72
73
this . $syncOptions ( true ) ;
73
74
}
74
75
76
+ // Auto update "updateCounter" and "ace_nomatch"
77
+ onEditorInput ( ) {
78
+ this . find ( false , false , true ) ;
79
+ }
80
+
75
81
/**
76
82
* @param {HTMLElement } sb
77
83
*/
@@ -219,6 +225,15 @@ class SearchBox {
219
225
? editor . session . getTextRange ( this . searchRange )
220
226
: editor . getValue ( ) ;
221
227
228
+ /**
229
+ * Convert all line ending variations to Unix-style = \n
230
+ * Windows (\r\n), MacOS Classic (\r), and Unix (\n)
231
+ */
232
+ if ( editor . $search . $isMultilineSearch ( editor . getLastSearchOptions ( ) ) ) {
233
+ value = value . replace ( / \r \n | \r | \n / g, "\n" ) ;
234
+ editor . session . doc . $autoNewLine = "\n" ;
235
+ }
236
+
222
237
var offset = editor . session . doc . positionToIndex ( editor . selection . anchor ) ;
223
238
if ( this . searchRange )
224
239
offset -= editor . session . doc . positionToIndex ( this . searchRange . start ) ;
@@ -279,6 +294,7 @@ class SearchBox {
279
294
this . active = false ;
280
295
this . setSearchRange ( null ) ;
281
296
this . editor . off ( "changeSession" , this . setSession ) ;
297
+ this . editor . off ( "input" , this . $onEditorInput ) ;
282
298
283
299
this . element . style . display = "none" ;
284
300
this . editor . keyBinding . removeKeyboardHandler ( this . $closeSearchBarKb ) ;
@@ -292,9 +308,13 @@ class SearchBox {
292
308
show ( value , isReplace ) {
293
309
this . active = true ;
294
310
this . editor . on ( "changeSession" , this . setSession ) ;
311
+ this . editor . on ( "input" , this . $onEditorInput ) ;
295
312
this . element . style . display = "" ;
296
313
this . replaceOption . checked = isReplace ;
297
314
315
+ if ( this . editor . $search . $options . regExp )
316
+ value = lang . escapeRegExp ( value ) ;
317
+
298
318
if ( value )
299
319
this . searchInput . value = value ;
300
320
0 commit comments