@@ -56,14 +56,21 @@ suite('SelectionInfoBuilder', () => {
5656
5757 test ( 'it sorts the selections by ascending order of line number' , ( ) => {
5858 const selections = [
59- { start : { line : 5 } , end : { line : 6 } } ,
60- { start : { line : 1 } , end : { line : 2 } }
59+ { start : { line : 5 } , end : { line : 6 } , text : 'A' } ,
60+ { start : { line : 1 } , end : { line : 2 } , text : 'B' }
6161 ] ;
6262 const textInfo = extractTextInfoFromSelections ( selections ) ;
63- expect ( textInfo . lineRanges ) . to . eql ( [
64- { start : 1 , end : 2 } ,
65- { start : 5 , end : 6 }
66- ] ) ;
63+ expect ( textInfo . text ) . to . eql ( 'B\nA' ) ;
64+ } ) ;
65+
66+ test ( 'it sorts the selections by ascending order of column number if in the same line' , ( ) => {
67+ const selections = [
68+ { start : { line : 5 , character : 7 } , end : { line : 5 , character : 8 } , text : 'A' } ,
69+ { start : { line : 5 , character : 4 } , end : { line : 5 , character : 5 } , text : 'B' } ,
70+ { start : { line : 1 , character : 1 } , end : { line : 1 , character : 2 } , text : 'C' }
71+ ] ;
72+ const textInfo = extractTextInfoFromSelections ( selections ) ;
73+ expect ( textInfo . text ) . to . eql ( 'C\nB\nA' ) ;
6774 } ) ;
6875
6976 test ( 'it extracts a file name from editor' , ( ) => {
@@ -75,15 +82,16 @@ suite('SelectionInfoBuilder', () => {
7582 const selections = selectedTexts . map ( ( text , i ) => ( {
7683 text,
7784 start : { line : `START_LINE_${ i + 1 } ` } ,
78- end : { line : `END_LINE_${ i + 1 } ` } ,
79- isEmpty : ! text
85+ end : { line : `END_LINE_${ i + 1 } ` }
8086 } ) ) ;
8187 return extractTextInfoFromSelections ( selections ) ;
8288 }
8389
8490 function extractTextInfoFromSelections ( selections ) {
8591 const selectionInfoBuilder = new SelectionInfoBuilder ( ) ;
86- return selectionInfoBuilder . extract ( fakeEditor ( selections ) ) ;
92+ const selectionWithIsEmptyFlag = selections
93+ . map ( s => Object . assign ( { } , s , { isEmpty : ! s . text } ) ) ;
94+ return selectionInfoBuilder . extract ( fakeEditor ( selectionWithIsEmptyFlag ) ) ;
8795 }
8896
8997 function fakeEditor ( selections ) {
0 commit comments