@@ -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 ( ) {
@@ -422,15 +432,7 @@ define(function (require, exports, module) {
422432 waitsForSearchBarClose ( ) ;
423433
424434 runs ( function ( ) {
425- expectSelection ( capitalFooSelections [ 0 ] ) ;
426- twCommandManager . execute ( Commands . EDIT_FIND_NEXT ) ;
427- expectSelection ( capitalFooSelections [ 1 ] ) ;
428- twCommandManager . execute ( Commands . EDIT_FIND_NEXT ) ;
429- expectSelection ( capitalFooSelections [ 2 ] ) ;
430-
431- // next find should wraparound since it should skip the lowercase "foo()"
432- twCommandManager . execute ( Commands . EDIT_FIND_NEXT ) ;
433- expectSelection ( capitalFooSelections [ 0 ] ) ;
435+ expectFindNextSelections ( capitalFooSelections ) ;
434436 } ) ;
435437 } ) ;
436438
@@ -695,6 +697,37 @@ define(function (require, exports, module) {
695697 expectSelection ( expectedSelections [ 0 ] ) ;
696698 } ) ;
697699
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+
698731 it ( "toggling regexp option should update results immediately" , function ( ) {
699732 myEditor . setCursorPos ( 0 , 0 ) ;
700733
@@ -745,7 +778,7 @@ define(function (require, exports, module) {
745778 expectHighlightedMatches ( expectedSelections ) ;
746779 expectSelection ( expectedSelections [ 0 ] ) ;
747780 } ) ;
748-
781+
749782 it ( "shouldn't choke on invalid regexp" , function ( ) {
750783 myEditor . setCursorPos ( 0 , 0 ) ;
751784
0 commit comments