File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ export default class Bundle {
246246
247247 return (
248248 Object . keys ( indentStringCounts ) . sort ( ( a , b ) => {
249- return indentStringCounts [ a ] - indentStringCounts [ b ]
249+ return indentStringCounts [ b ] - indentStringCounts [ a ]
250250 } ) [ 0 ] || '\t'
251251 )
252252 }
Original file line number Diff line number Diff line change @@ -640,6 +640,26 @@ describe('bundle', () => {
640640 assert . equal ( b . toString ( ) , ' abcdef\n ghijkl\n mnopqr' )
641641 } )
642642
643+ it ( 'should guess the most common indentation' , ( ) => {
644+ const b = new Bundle ( )
645+
646+ b . addSource ( { content : new MagicString ( ' abc' ) } )
647+ b . addSource ( { content : new MagicString ( ' def' ) } )
648+ b . addSource ( { content : new MagicString ( ' ghi' ) } )
649+
650+ assert . equal ( b . getIndentString ( ) , ' ' )
651+ } )
652+
653+ it ( 'should not let a single source outvote the rest' , ( ) => {
654+ const b = new Bundle ( )
655+
656+ b . addSource ( { content : new MagicString ( ' abc' ) } )
657+ b . addSource ( { content : new MagicString ( ' def' ) } )
658+ b . addSource ( { content : new MagicString ( ' ghi' ) } )
659+
660+ assert . equal ( b . getIndentString ( ) , ' ' )
661+ } )
662+
643663 it ( 'should respect indent exclusion ranges' , ( ) => {
644664 const b = new Bundle ( )
645665
You can’t perform that action at this time.
0 commit comments