@@ -940,13 +940,23 @@ declare var console: {
940
940
} )
941
941
} ;
942
942
const fooBar : File = {
943
- path : `${ tscWatch . projectRoot } /src/fooBar.ts` ,
943
+ path : `${ tscWatch . projectRoot } /src/sub/ fooBar.ts` ,
944
944
content : "export function fooBar() { }"
945
945
} ;
946
- function verifySessionWorker ( { openFileBeforeCreating, checkProjectBeforeError, checkProjectAfterError, } : VerifySession , errorOnNewFileBeforeOldFile : boolean ) {
947
- const host = createServerHost ( [ foo , bar , config , libFile ] ) ;
946
+ function verifySessionWorker ( { withExclude, openFileBeforeCreating, checkProjectBeforeError, checkProjectAfterError, } : VerifySession , errorOnNewFileBeforeOldFile : boolean ) {
947
+ const host = createServerHost ( [
948
+ foo , bar , libFile , { path : `${ tscWatch . projectRoot } /src/sub` } ,
949
+ withExclude ?
950
+ {
951
+ path : config . path ,
952
+ content : JSON . stringify ( {
953
+ include : [ "./src" ] ,
954
+ exclude : [ "./src/sub" ]
955
+ } )
956
+ } :
957
+ config
958
+ ] ) ;
948
959
const session = createSession ( host , {
949
- //logger: createLoggerWritingToConsole(),
950
960
canUseEvents : true
951
961
} ) ;
952
962
session . executeCommandSeq < protocol . OpenRequest > ( {
@@ -990,6 +1000,7 @@ declare var console: {
990
1000
checkProjectAfterError ( service ) ;
991
1001
}
992
1002
interface VerifySession {
1003
+ withExclude ?: boolean ;
993
1004
openFileBeforeCreating : boolean ;
994
1005
checkProjectBeforeError : ( service : server . ProjectService ) => void ;
995
1006
checkProjectAfterError : ( service : server . ProjectService ) => void ;
@@ -1003,35 +1014,53 @@ declare var console: {
1003
1014
verifySessionWorker ( input , /*errorOnNewFileBeforeOldFile*/ false ) ;
1004
1015
} ) ;
1005
1016
}
1017
+ function checkFooBarInInferredProject ( service : server . ProjectService ) {
1018
+ checkNumberOfProjects ( service , { configuredProjects : 1 , inferredProjects : 1 } ) ;
1019
+ checkProjectActualFiles ( service . configuredProjects . get ( config . path ) ! , [ foo . path , bar . path , libFile . path , config . path ] ) ;
1020
+ checkProjectActualFiles ( service . inferredProjects [ 0 ] , [ fooBar . path , libFile . path ] ) ;
1021
+ }
1022
+ function checkFooBarInConfiguredProject ( service : server . ProjectService ) {
1023
+ checkNumberOfProjects ( service , { configuredProjects : 1 } ) ;
1024
+ checkProjectActualFiles ( service . configuredProjects . get ( config . path ) ! , [ foo . path , bar . path , fooBar . path , libFile . path , config . path ] ) ;
1025
+ }
1006
1026
describe ( "when new file creation directory watcher is invoked before file is opened in editor" , ( ) => {
1007
1027
verifySession ( {
1008
1028
openFileBeforeCreating : false ,
1009
- checkProjectBeforeError : service => {
1010
- checkNumberOfProjects ( service , { configuredProjects : 1 } ) ;
1011
- checkProjectActualFiles ( service . configuredProjects . get ( config . path ) ! , [ foo . path , bar . path , fooBar . path , libFile . path , config . path ] ) ;
1012
- } ,
1013
- checkProjectAfterError : service => {
1014
- checkNumberOfProjects ( service , { configuredProjects : 1 } ) ;
1015
- checkProjectActualFiles ( service . configuredProjects . get ( config . path ) ! , [ foo . path , bar . path , fooBar . path , libFile . path , config . path ] ) ;
1016
- }
1029
+ checkProjectBeforeError : checkFooBarInConfiguredProject ,
1030
+ checkProjectAfterError : checkFooBarInConfiguredProject
1031
+ } ) ;
1032
+ describe ( "when new file is excluded from config" , ( ) => {
1033
+ verifySession ( {
1034
+ withExclude : true ,
1035
+ openFileBeforeCreating : false ,
1036
+ checkProjectBeforeError : checkFooBarInInferredProject ,
1037
+ checkProjectAfterError : checkFooBarInInferredProject
1038
+ } ) ;
1017
1039
} ) ;
1018
1040
} ) ;
1019
1041
1020
1042
describe ( "when new file creation directory watcher is invoked after file is opened in editor" , ( ) => {
1021
1043
verifySession ( {
1022
1044
openFileBeforeCreating : true ,
1023
- checkProjectBeforeError : service => {
1024
- checkNumberOfProjects ( service , { configuredProjects : 1 , inferredProjects : 1 } ) ;
1025
- checkProjectActualFiles ( service . configuredProjects . get ( config . path ) ! , [ foo . path , bar . path , libFile . path , config . path ] ) ;
1026
- checkProjectActualFiles ( service . inferredProjects [ 0 ] , [ fooBar . path , libFile . path ] ) ;
1027
- } ,
1045
+ checkProjectBeforeError : checkFooBarInInferredProject ,
1028
1046
checkProjectAfterError : service => {
1047
+ // Both projects exist but fooBar is in configured project after the update
1048
+ // Inferred project is yet to be updated so still has fooBar
1029
1049
checkNumberOfProjects ( service , { configuredProjects : 1 , inferredProjects : 1 } ) ;
1030
1050
checkProjectActualFiles ( service . configuredProjects . get ( config . path ) ! , [ foo . path , bar . path , fooBar . path , libFile . path , config . path ] ) ;
1031
1051
checkProjectActualFiles ( service . inferredProjects [ 0 ] , [ fooBar . path , libFile . path ] ) ;
1032
1052
assert . isTrue ( service . inferredProjects [ 0 ] . dirty ) ;
1053
+ assert . equal ( service . inferredProjects [ 0 ] . getRootFilesMap ( ) . size , 0 ) ;
1033
1054
}
1034
1055
} ) ;
1056
+ describe ( "when new file is excluded from config" , ( ) => {
1057
+ verifySession ( {
1058
+ withExclude : true ,
1059
+ openFileBeforeCreating : true ,
1060
+ checkProjectBeforeError : checkFooBarInInferredProject ,
1061
+ checkProjectAfterError : checkFooBarInInferredProject
1062
+ } ) ;
1063
+ } ) ;
1035
1064
} ) ;
1036
1065
} ) ;
1037
1066
} ) ;
0 commit comments