@@ -107,6 +107,16 @@ define(function (require, exports, module) {
107107 }
108108 expect ( actualHighlights . length ) . toEqual ( expectedDOMHighlightCount ) ;
109109 }
110+ function expectFindNextSelections ( selections ) {
111+ var i ;
112+ for ( i = 0 ; i < selections . length ; i ++ ) {
113+ expectSelection ( selections [ i ] ) ;
114+ twCommandManager . execute ( Commands . EDIT_FIND_NEXT ) ;
115+ }
116+
117+ // next find should wraparound
118+ expectSelection ( selections [ 0 ] ) ;
119+ }
110120
111121
112122 function getSearchBar ( ) {
@@ -407,6 +417,25 @@ define(function (require, exports, module) {
407417 } ) ;
408418 } ) ;
409419
420+ it ( "should Find Next after search bar closed, remembering case sensitivity state" , function ( ) {
421+ runs ( function ( ) {
422+ myEditor . setCursorPos ( 0 , 0 ) ;
423+
424+ twCommandManager . execute ( Commands . EDIT_FIND ) ;
425+
426+ toggleCaseSensitive ( true ) ;
427+ enterSearchText ( "Foo" ) ;
428+ pressEscape ( ) ;
429+ expectHighlightedMatches ( [ ] ) ;
430+ } ) ;
431+
432+ waitsForSearchBarClose ( ) ;
433+
434+ runs ( function ( ) {
435+ expectFindNextSelections ( capitalFooSelections ) ;
436+ } ) ;
437+ } ) ;
438+
410439 it ( "shouldn't Find Next after search bar reopened" , function ( ) {
411440 runs ( function ( ) {
412441 myEditor . setCursorPos ( 0 , 0 ) ;
@@ -668,6 +697,37 @@ define(function (require, exports, module) {
668697 expectSelection ( expectedSelections [ 0 ] ) ;
669698 } ) ;
670699
700+
701+ it ( "should Find Next after search bar closed, remembering last used regexp" , function ( ) {
702+ var expectedSelections = [
703+ { start : { line : LINE_FIRST_REQUIRE + 1 , ch : 8 } , end : { line : LINE_FIRST_REQUIRE + 1 , ch : 11 } } ,
704+ { start : { line : LINE_FIRST_REQUIRE + 1 , ch : 31 } , end : { line : LINE_FIRST_REQUIRE + 1 , ch : 34 } } ,
705+ { start : { line : LINE_FIRST_REQUIRE + 2 , ch : 8 } , end : { line : LINE_FIRST_REQUIRE + 2 , ch : 11 } } ,
706+ { start : { line : LINE_FIRST_REQUIRE + 2 , ch : 31 } , end : { line : LINE_FIRST_REQUIRE + 2 , ch : 34 } }
707+ ] ;
708+
709+ runs ( function ( ) {
710+ myEditor . setCursorPos ( 0 , 0 ) ;
711+
712+ twCommandManager . execute ( Commands . EDIT_FIND ) ;
713+
714+ toggleRegexp ( true ) ;
715+ enterSearchText ( "Ba." ) ;
716+ pressEscape ( ) ;
717+ expectHighlightedMatches ( [ ] ) ;
718+ } ) ;
719+
720+ waitsForSearchBarClose ( ) ;
721+
722+ runs ( function ( ) {
723+ expectFindNextSelections ( expectedSelections ) ;
724+
725+ // explicitly clean up since we closed the search bar
726+ twCommandManager . execute ( Commands . EDIT_FIND ) ;
727+ toggleRegexp ( false ) ;
728+ } ) ;
729+ } ) ;
730+
671731 it ( "toggling regexp option should update results immediately" , function ( ) {
672732 myEditor . setCursorPos ( 0 , 0 ) ;
673733
@@ -718,7 +778,7 @@ define(function (require, exports, module) {
718778 expectHighlightedMatches ( expectedSelections ) ;
719779 expectSelection ( expectedSelections [ 0 ] ) ;
720780 } ) ;
721-
781+
722782 it ( "shouldn't choke on invalid regexp" , function ( ) {
723783 myEditor . setCursorPos ( 0 , 0 ) ;
724784
0 commit comments