@@ -1050,6 +1050,64 @@ declare var console: {
1050
1050
} ) ;
1051
1051
} ) ;
1052
1052
} ) ;
1053
+
1054
+ it ( "when default configured project does not contain the file" , ( ) => {
1055
+ const barConfig : File = {
1056
+ path : `${ tscWatch . projectRoot } /bar/tsconfig.json` ,
1057
+ content : "{}"
1058
+ } ;
1059
+ const barIndex : File = {
1060
+ path : `${ tscWatch . projectRoot } /bar/index.ts` ,
1061
+ content : `import {foo} from "../foo/lib";
1062
+ foo();`
1063
+ } ;
1064
+ const fooBarConfig : File = {
1065
+ path : `${ tscWatch . projectRoot } /foobar/tsconfig.json` ,
1066
+ content : barConfig . path
1067
+ } ;
1068
+ const fooBarIndex : File = {
1069
+ path : `${ tscWatch . projectRoot } /foobar/index.ts` ,
1070
+ content : barIndex . content
1071
+ } ;
1072
+ const fooConfig : File = {
1073
+ path : `${ tscWatch . projectRoot } /foo/tsconfig.json` ,
1074
+ content : JSON . stringify ( {
1075
+ include : [ "index.ts" ] ,
1076
+ compilerOptions : {
1077
+ declaration : true ,
1078
+ outDir : "lib"
1079
+ }
1080
+ } )
1081
+ } ;
1082
+ const fooIndex : File = {
1083
+ path : `${ tscWatch . projectRoot } /foo/index.ts` ,
1084
+ content : `export function foo() {}`
1085
+ } ;
1086
+ const host = createServerHost ( [ barConfig , barIndex , fooBarConfig , fooBarIndex , fooConfig , fooIndex , libFile ] ) ;
1087
+ tscWatch . ensureErrorFreeBuild ( host , [ fooConfig . path ] ) ;
1088
+ const fooDts = `${ tscWatch . projectRoot } /foo/lib/index.d.ts` ;
1089
+ assert . isTrue ( host . fileExists ( fooDts ) ) ;
1090
+ const session = createSession ( host ) ;
1091
+ const service = session . getProjectService ( ) ;
1092
+ service . openClientFile ( barIndex . path ) ;
1093
+ checkProjectActualFiles ( service . configuredProjects . get ( barConfig . path ) ! , [ barIndex . path , fooDts , libFile . path , barConfig . path ] ) ;
1094
+ service . openClientFile ( fooBarIndex . path ) ;
1095
+ checkProjectActualFiles ( service . configuredProjects . get ( fooBarConfig . path ) ! , [ fooBarIndex . path , fooDts , libFile . path , fooBarConfig . path ] ) ;
1096
+ service . openClientFile ( fooIndex . path ) ;
1097
+ checkProjectActualFiles ( service . configuredProjects . get ( fooConfig . path ) ! , [ fooIndex . path , libFile . path , fooConfig . path ] ) ;
1098
+ service . openClientFile ( fooDts ) ;
1099
+ session . executeCommandSeq < protocol . GetApplicableRefactorsRequest > ( {
1100
+ command : protocol . CommandTypes . GetApplicableRefactors ,
1101
+ arguments : {
1102
+ file : fooDts ,
1103
+ startLine : 1 ,
1104
+ startOffset : 1 ,
1105
+ endLine : 1 ,
1106
+ endOffset : 1
1107
+ }
1108
+ } ) ;
1109
+ assert . equal ( service . tryGetDefaultProjectForFile ( server . toNormalizedPath ( fooDts ) ) , service . configuredProjects . get ( barConfig . path ) ) ;
1110
+ } ) ;
1053
1111
} ) ;
1054
1112
1055
1113
describe ( "unittests:: tsserver:: ConfiguredProjects:: non-existing directories listed in config file input array" , ( ) => {
0 commit comments