@@ -605,27 +605,40 @@ define(function (require, exports, module) {
605605 it ( "should return empty string for a cursor" , function ( ) {
606606 myEditor . _codeMirror . setCursor ( 0 , 2 ) ;
607607 expect ( myEditor . getSelectedText ( ) ) . toEqual ( "" ) ;
608+ expect ( myEditor . getSelectedText ( true ) ) . toEqual ( "" ) ;
608609 } ) ;
609610
610611 it ( "should return the contents of a single selection" , function ( ) {
611- myEditor . _codeMirror . setSelection ( { line : 0 , ch : 8 } , { line : 0 , ch : 12 } ) ;
612- expect ( myEditor . getSelectedText ( ) ) . toEqual ( "line" ) ;
612+ myEditor . _codeMirror . setSelection ( { line : 0 , ch : 8 } , { line : 0 , ch : 14 } ) ;
613+ expect ( myEditor . getSelectedText ( ) ) . toEqual ( "line 0" ) ;
614+ expect ( myEditor . getSelectedText ( true ) ) . toEqual ( "line 0" ) ;
613615 } ) ;
614616
615- it ( "should return the contents of a multiple selection, separated by newlines " , function ( ) {
616- myEditor . _codeMirror . setSelections ( [ { anchor : { line : 0 , ch : 8 } , head : { line : 0 , ch : 12 } } ,
617- { anchor : { line : 1 , ch : 8 } , head : { line : 1 , ch : 12 } } ,
618- { anchor : { line : 2 , ch : 8 } , head : { line : 2 , ch : 12 } }
617+ it ( "should return the primary selection by default, but concatenate contents if allSelections is true " , function ( ) {
618+ myEditor . _codeMirror . setSelections ( [ { anchor : { line : 0 , ch : 8 } , head : { line : 0 , ch : 14 } } ,
619+ { anchor : { line : 1 , ch : 8 } , head : { line : 1 , ch : 14 } } ,
620+ { anchor : { line : 2 , ch : 8 } , head : { line : 2 , ch : 14 } }
619621 ] ) ;
620- expect ( myEditor . getSelectedText ( ) ) . toEqual ( "line\nline\nline" ) ;
622+ expect ( myEditor . getSelectedText ( ) ) . toEqual ( "line 2" ) ;
623+ expect ( myEditor . getSelectedText ( true ) ) . toEqual ( "line 0\nline 1\nline 2" ) ;
624+ } ) ;
625+
626+ it ( "should return a primary selection other than the last" , function ( ) {
627+ myEditor . _codeMirror . setSelections ( [ { anchor : { line : 0 , ch : 8 } , head : { line : 0 , ch : 14 } } ,
628+ { anchor : { line : 1 , ch : 8 } , head : { line : 1 , ch : 14 } } ,
629+ { anchor : { line : 2 , ch : 8 } , head : { line : 2 , ch : 14 } }
630+ ] , 1 ) ;
631+ expect ( myEditor . getSelectedText ( ) ) . toEqual ( "line 1" ) ;
632+ expect ( myEditor . getSelectedText ( true ) ) . toEqual ( "line 0\nline 1\nline 2" ) ;
621633 } ) ;
622634
623635 it ( "should return the contents of a multiple selection when some selections are reversed" , function ( ) {
624- myEditor . _codeMirror . setSelections ( [ { anchor : { line : 0 , ch : 12 } , head : { line : 0 , ch : 8 } } ,
625- { anchor : { line : 1 , ch : 8 } , head : { line : 1 , ch : 12 } } ,
626- { anchor : { line : 2 , ch : 12 } , head : { line : 2 , ch : 8 } }
636+ myEditor . _codeMirror . setSelections ( [ { anchor : { line : 0 , ch : 14 } , head : { line : 0 , ch : 8 } } ,
637+ { anchor : { line : 1 , ch : 8 } , head : { line : 1 , ch : 14 } } ,
638+ { anchor : { line : 2 , ch : 14 } , head : { line : 2 , ch : 8 } }
627639 ] ) ;
628- expect ( myEditor . getSelectedText ( ) ) . toEqual ( "line\nline\nline" ) ;
640+ expect ( myEditor . getSelectedText ( ) ) . toEqual ( "line 2" ) ;
641+ expect ( myEditor . getSelectedText ( true ) ) . toEqual ( "line 0\nline 1\nline 2" ) ;
629642 } ) ;
630643 } ) ;
631644
0 commit comments