@@ -140,7 +140,6 @@ namespace ts.projectSystem {
140
140
export interface TestServerHostCreationParameters {
141
141
useCaseSensitiveFileNames ?: boolean ;
142
142
executingFilePath ?: string ;
143
- libFile ?: FileOrFolder ;
144
143
currentDirectory ?: string ;
145
144
}
146
145
@@ -1145,6 +1144,69 @@ namespace ts.projectSystem {
1145
1144
checkNumberOfProjects ( projectService , { } ) ;
1146
1145
} ) ;
1147
1146
1147
+ it ( "reload regular file after closing" , ( ) => {
1148
+ const f1 = {
1149
+ path : "/a/b/app.ts" ,
1150
+ content : "x."
1151
+ } ;
1152
+ const f2 = {
1153
+ path : "/a/b/lib.ts" ,
1154
+ content : "let x: number;"
1155
+ } ;
1156
+
1157
+ const host = createServerHost ( [ f1 , f2 , libFile ] ) ;
1158
+ const service = createProjectService ( host ) ;
1159
+ service . openExternalProject ( { projectFileName : "/a/b/project" , rootFiles : toExternalFiles ( [ f1 . path , f2 . path ] ) , options : { } } )
1160
+
1161
+ service . openClientFile ( f1 . path ) ;
1162
+ service . openClientFile ( f2 . path , "let x: string" ) ;
1163
+
1164
+ service . checkNumberOfProjects ( { externalProjects : 1 } ) ;
1165
+ checkProjectActualFiles ( service . externalProjects [ 0 ] , [ f1 . path , f2 . path , libFile . path ] ) ;
1166
+
1167
+ const completions1 = service . externalProjects [ 0 ] . getLanguageService ( ) . getCompletionsAtPosition ( f1 . path , 2 ) ;
1168
+ // should contain completions for string
1169
+ assert . isTrue ( completions1 . entries . some ( e => e . name === "charAt" ) , "should contain 'charAt'" ) ;
1170
+ assert . isFalse ( completions1 . entries . some ( e => e . name === "toExponential" ) , "should not contain 'toExponential'" ) ;
1171
+
1172
+ service . closeClientFile ( f2 . path ) ;
1173
+ const completions2 = service . externalProjects [ 0 ] . getLanguageService ( ) . getCompletionsAtPosition ( f1 . path , 2 ) ;
1174
+ // should contain completions for string
1175
+ assert . isFalse ( completions2 . entries . some ( e => e . name === "charAt" ) , "should not contain 'charAt'" ) ;
1176
+ assert . isTrue ( completions2 . entries . some ( e => e . name === "toExponential" ) , "should contain 'toExponential'" ) ;
1177
+ } ) ;
1178
+
1179
+ it ( "clear mixed content file after closing" , ( ) => {
1180
+ const f1 = {
1181
+ path : "/a/b/app.ts" ,
1182
+ content : " "
1183
+ } ;
1184
+ const f2 = {
1185
+ path : "/a/b/lib.html" ,
1186
+ content : "<html/>"
1187
+ } ;
1188
+
1189
+ const host = createServerHost ( [ f1 , f2 , libFile ] ) ;
1190
+ const service = createProjectService ( host ) ;
1191
+ service . openExternalProject ( { projectFileName : "/a/b/project" , rootFiles : [ { fileName : f1 . path } , { fileName : f2 . path , hasMixedContent : true } ] , options : { } } )
1192
+
1193
+ service . openClientFile ( f1 . path ) ;
1194
+ service . openClientFile ( f2 . path , "let somelongname: string" ) ;
1195
+
1196
+ service . checkNumberOfProjects ( { externalProjects : 1 } ) ;
1197
+ checkProjectActualFiles ( service . externalProjects [ 0 ] , [ f1 . path , f2 . path , libFile . path ] ) ;
1198
+
1199
+ const completions1 = service . externalProjects [ 0 ] . getLanguageService ( ) . getCompletionsAtPosition ( f1 . path , 0 ) ;
1200
+ assert . isTrue ( completions1 . entries . some ( e => e . name === "somelongname" ) , "should contain 'somelongname'" ) ;
1201
+
1202
+ service . closeClientFile ( f2 . path ) ;
1203
+ const completions2 = service . externalProjects [ 0 ] . getLanguageService ( ) . getCompletionsAtPosition ( f1 . path , 0 ) ;
1204
+ assert . isFalse ( completions2 . entries . some ( e => e . name === "somelongname" ) , "should not contain 'somelongname'" ) ;
1205
+ const sf2 = service . externalProjects [ 0 ] . getLanguageService ( ) . getProgram ( ) . getSourceFile ( f2 . path ) ;
1206
+ assert . equal ( sf2 . text , "" ) ;
1207
+ } ) ;
1208
+
1209
+
1148
1210
it ( "external project with included config file opened after configured project" , ( ) => {
1149
1211
const file1 = {
1150
1212
path : "/a/b/f1.ts" ,
0 commit comments