@@ -1054,7 +1054,7 @@ namespace ts.projectSystem {
1054
1054
assert . equal ( options . outDir , "C:/a/b" , "" ) ;
1055
1055
} ) ;
1056
1056
1057
- it ( "files opened, closed affecting multiple projects" , ( ) => {
1057
+ it ( "files opened and closed affecting multiple projects" , ( ) => {
1058
1058
const file : File = {
1059
1059
path : "/a/b/projects/config/file.ts" ,
1060
1060
content : `import {a} from "../files/file1"; export let b = a;`
@@ -1074,7 +1074,7 @@ namespace ts.projectSystem {
1074
1074
1075
1075
const files = [ config , file , filesFile1 , filesFile2 , libFile ] ;
1076
1076
const host = createServerHost ( files ) ;
1077
- const session = createSession ( host ) ;
1077
+ const session = createSession ( host , { logger : createLoggerWithInMemoryLogs ( ) } ) ;
1078
1078
// Create configured project
1079
1079
session . executeCommandSeq < protocol . OpenRequest > ( {
1080
1080
command : protocol . CommandTypes . Open ,
@@ -1083,18 +1083,13 @@ namespace ts.projectSystem {
1083
1083
}
1084
1084
} ) ;
1085
1085
1086
- const projectService = session . getProjectService ( ) ;
1087
- const configuredProject = projectService . configuredProjects . get ( config . path ) ! ;
1088
- verifyConfiguredProject ( ) ;
1089
-
1090
1086
// open files/file1 = should not create another project
1091
1087
session . executeCommandSeq < protocol . OpenRequest > ( {
1092
1088
command : protocol . CommandTypes . Open ,
1093
1089
arguments : {
1094
1090
file : filesFile1 . path
1095
1091
}
1096
1092
} ) ;
1097
- verifyConfiguredProject ( ) ;
1098
1093
1099
1094
// Close the file = should still have project
1100
1095
session . executeCommandSeq < protocol . CloseRequest > ( {
@@ -1103,7 +1098,6 @@ namespace ts.projectSystem {
1103
1098
file : file . path
1104
1099
}
1105
1100
} ) ;
1106
- verifyConfiguredProject ( ) ;
1107
1101
1108
1102
// Open files/file2 - should create inferred project and close configured project
1109
1103
session . executeCommandSeq < protocol . OpenRequest > ( {
@@ -1112,8 +1106,6 @@ namespace ts.projectSystem {
1112
1106
file : filesFile2 . path
1113
1107
}
1114
1108
} ) ;
1115
- checkNumberOfProjects ( projectService , { inferredProjects : 1 } ) ;
1116
- checkProjectActualFiles ( projectService . inferredProjects [ 0 ] , [ libFile . path , filesFile2 . path ] ) ;
1117
1109
1118
1110
// Actions on file1 would result in assert
1119
1111
session . executeCommandSeq < protocol . OccurrencesRequest > ( {
@@ -1125,10 +1117,7 @@ namespace ts.projectSystem {
1125
1117
}
1126
1118
} ) ;
1127
1119
1128
- function verifyConfiguredProject ( ) {
1129
- checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1130
- checkProjectActualFiles ( configuredProject , [ file . path , filesFile1 . path , libFile . path , config . path ] ) ;
1131
- }
1120
+ baselineTsserverLogs ( "projects" , "files opened and closed affecting multiple projects" , session ) ;
1132
1121
} ) ;
1133
1122
1134
1123
it ( "requests are done on file on pendingReload but has svc for previous version" , ( ) => {
@@ -1620,5 +1609,40 @@ namespace ts.projectSystem {
1620
1609
1621
1610
checkNumberOfInferredProjects ( projectService , 0 ) ;
1622
1611
} ) ;
1612
+
1613
+ it ( "file opened is in configured project that will be removed" , ( ) => {
1614
+ const testsConfig : File = {
1615
+ path : `${ tscWatch . projectRoot } /playground/tsconfig.json` ,
1616
+ content : "{}"
1617
+ } ;
1618
+ const testsFile : File = {
1619
+ path : `${ tscWatch . projectRoot } /playground/tests.ts` ,
1620
+ content : `export function foo() {}`
1621
+ } ;
1622
+ const innerFile : File = {
1623
+ path : `${ tscWatch . projectRoot } /playground/tsconfig-json/tests/spec.ts` ,
1624
+ content : `export function bar() { }`
1625
+ } ;
1626
+ const innerConfig : File = {
1627
+ path : `${ tscWatch . projectRoot } /playground/tsconfig-json/tsconfig.json` ,
1628
+ content : JSON . stringify ( {
1629
+ include : [ "./src" ]
1630
+ } )
1631
+ } ;
1632
+ const innerSrcFile : File = {
1633
+ path : `${ tscWatch . projectRoot } /playground/tsconfig-json/src/src.ts` ,
1634
+ content : `export function foobar() { }`
1635
+ } ;
1636
+ const host = createServerHost ( [ testsConfig , testsFile , innerFile , innerConfig , innerSrcFile , libFile ] ) ;
1637
+ const session = createSession ( host , { logger : createLoggerWithInMemoryLogs ( ) } ) ;
1638
+ openFilesForSession ( [ testsFile ] , session ) ;
1639
+ closeFilesForSession ( [ testsFile ] , session ) ;
1640
+ openFilesForSession ( [ innerFile ] , session ) ;
1641
+ session . executeCommandSeq < protocol . OutliningSpansRequest > ( {
1642
+ command : protocol . CommandTypes . GetOutliningSpans ,
1643
+ arguments : { file : innerFile . path }
1644
+ } ) ;
1645
+ baselineTsserverLogs ( "projects" , "file opened is in configured project that will be removed" , session ) ;
1646
+ } ) ;
1623
1647
} ) ;
1624
1648
}
0 commit comments