@@ -1840,6 +1840,41 @@ namespace ts.projectSystem {
1840
1840
assert . isFalse ( service . externalProjects [ 0 ] . languageServiceEnabled , "language service should be disabled - 2" ) ;
1841
1841
} ) ;
1842
1842
1843
+ it ( "files are properly detached when language service is disabled" , ( ) => {
1844
+ const f1 = {
1845
+ path : "/a/app.js" ,
1846
+ content : "var x = 1"
1847
+ } ;
1848
+ const f2 = {
1849
+ path : "/a/largefile.js" ,
1850
+ content : ""
1851
+ } ;
1852
+ const f3 = {
1853
+ path : "/a/lib.js" ,
1854
+ content : "var x = 1"
1855
+ } ;
1856
+ const config = {
1857
+ path : "/a/tsconfig.json" ,
1858
+ content : JSON . stringify ( { compilerOptions : { allowJs : true } } )
1859
+ } ;
1860
+ const host = createServerHost ( [ f1 , f2 , f3 , config ] ) ;
1861
+ const originalGetFileSize = host . getFileSize ;
1862
+ host . getFileSize = ( filePath : string ) =>
1863
+ filePath === f2 . path ? server . maxProgramSizeForNonTsFiles + 1 : originalGetFileSize . call ( host , filePath ) ;
1864
+
1865
+ const projectService = createProjectService ( host ) ;
1866
+ projectService . openClientFile ( f1 . path ) ;
1867
+ projectService . checkNumberOfProjects ( { configuredProjects : 1 } ) ;
1868
+
1869
+ projectService . closeClientFile ( f1 . path ) ;
1870
+ projectService . checkNumberOfProjects ( { } ) ;
1871
+
1872
+ for ( const f of [ f2 , f3 ] ) {
1873
+ const scriptInfo = projectService . getScriptInfoForNormalizedPath ( server . toNormalizedPath ( f . path ) ) ;
1874
+ assert . equal ( scriptInfo . containingProjects . length , 0 , `expect 0 containing projects for '${ f . path } '` )
1875
+ }
1876
+ } ) ;
1877
+
1843
1878
it ( "language service disabled events are triggered" , ( ) => {
1844
1879
const f1 = {
1845
1880
path : "/a/app.js" ,
0 commit comments