@@ -465,30 +465,30 @@ module ts {
465465 }
466466
467467 let sourcePathComponents = getNormalizedPathComponents ( sourceFile . fileName , currentDirectory ) ;
468- sourcePathComponents . pop ( ) ; // FileName is not part of directory
469- if ( commonPathComponents ) {
470- for ( let i = 0 , n = Math . min ( commonPathComponents . length , sourcePathComponents . length ) ; i < n ; i ++ ) {
471- if ( commonPathComponents [ i ] !== sourcePathComponents [ i ] ) {
472- if ( i === 0 ) {
473- diagnostics . add ( createCompilerDiagnostic ( Diagnostics . Cannot_find_the_common_subdirectory_path_for_the_input_files ) ) ;
474- return ;
475- }
468+ sourcePathComponents . pop ( ) ; // The base file name is not part of the common directory path
469+
470+ if ( ! commonPathComponents ) {
471+ // first file
472+ commonPathComponents = sourcePathComponents ;
473+ return ;
474+ }
476475
477- // New common path found that is 0 -> i-1
478- commonPathComponents . length = i ;
479- break ;
476+ for ( let i = 0 , n = Math . min ( commonPathComponents . length , sourcePathComponents . length ) ; i < n ; i ++ ) {
477+ if ( commonPathComponents [ i ] !== sourcePathComponents [ i ] ) {
478+ if ( i === 0 ) {
479+ diagnostics . add ( createCompilerDiagnostic ( Diagnostics . Cannot_find_the_common_subdirectory_path_for_the_input_files ) ) ;
480+ return ;
480481 }
481- }
482482
483- // If the fileComponent path completely matched and less than already found update the length
484- if ( sourcePathComponents . length < commonPathComponents . length ) {
485- commonPathComponents . length = sourcePathComponents . length ;
483+ // New common path found that is 0 -> i-1
484+ commonPathComponents . length = i ;
485+ break ;
486486 }
487487 }
488- else {
489- // first file
490- commonPathComponents = sourcePathComponents ;
491- return ;
488+
489+ // If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents
490+ if ( sourcePathComponents . length < commonPathComponents . length ) {
491+ commonPathComponents . length = sourcePathComponents . length ;
492492 }
493493 } ) ;
494494
0 commit comments