@@ -910,6 +910,94 @@ func TestSession(t *testing.T) {
910910 assert .Equal (t , len (program .GetSemanticDiagnostics (projecttestutil .WithRequestID (t .Context ()), program .GetSourceFile ("/home/projects/TS/p1/src/index.ts" ))), 1 )
911911 })
912912
913+ t .Run ("delete sibling folder schedules diagnostics refresh" , func (t * testing.T ) {
914+ t .Parallel ()
915+ files := map [string ]any {
916+ "/home/projects/TS/p1/tsconfig.json" : `{
917+ "compilerOptions": {
918+ "noLib": true
919+ },
920+ "files": ["index.ts"]
921+ }` ,
922+ "/home/projects/TS/p1/index.ts" : `import { content } from "./f/content";
923+
924+ export const value = content;` ,
925+ "/home/projects/TS/p1/f/content.ts" : `export const content = 1;` ,
926+ }
927+ session , utils := projecttestutil .Setup (files )
928+ contentURI := lsproto .DocumentUri ("file:///home/projects/TS/p1/f/content.ts" )
929+ session .DidOpenFile (context .Background (), "file:///home/projects/TS/p1/index.ts" , 1 , files ["/home/projects/TS/p1/index.ts" ].(string ), lsproto .LanguageKindTypeScript )
930+ session .DidOpenFile (context .Background (), contentURI , 1 , files ["/home/projects/TS/p1/f/content.ts" ].(string ), lsproto .LanguageKindTypeScript )
931+
932+ _ , err := session .GetLanguageService (context .Background (), "file:///home/projects/TS/p1/index.ts" )
933+ assert .NilError (t , err )
934+ session .WaitForBackgroundTasks ()
935+
936+ baselineRefreshCount := len (utils .Client ().RefreshDiagnosticsCalls ())
937+
938+ err = utils .FS ().Remove ("/home/projects/TS/p1/f" )
939+ assert .NilError (t , err )
940+
941+ session .DidChangeWatchedFiles (context .Background (), []* lsproto.FileEvent {
942+ {
943+ Type : lsproto .FileChangeTypeDeleted ,
944+ Uri : "file:///home/projects/TS/p1/f" ,
945+ },
946+ })
947+ session .DidCloseFile (context .Background (), contentURI )
948+ session .WaitForBackgroundTasks ()
949+
950+ refreshCount := len (utils .Client ().RefreshDiagnosticsCalls ())
951+ assert .Assert (t , refreshCount > baselineRefreshCount ,
952+ "expected RefreshDiagnostics to be called after deleting /home/projects/TS/p1/f, got %d calls (baseline %d)" ,
953+ refreshCount , baselineRefreshCount )
954+ })
955+
956+ t .Run ("delete sibling folder schedules diagnostics refresh after opening third file" , func (t * testing.T ) {
957+ t .Parallel ()
958+ files := map [string ]any {
959+ "/home/projects/TS/p1/tsconfig.json" : `{
960+ "compilerOptions": {
961+ "noLib": true
962+ },
963+ "files": ["index.ts", "third.ts"]
964+ }` ,
965+ "/home/projects/TS/p1/index.ts" : `import { content } from "./f/content";
966+
967+ export const value = content;` ,
968+ "/home/projects/TS/p1/f/content.ts" : `export const content = 1;` ,
969+ "/home/projects/TS/p1/third.ts" : `export const third = 3;` ,
970+ }
971+ session , utils := projecttestutil .Setup (files )
972+ contentURI := lsproto .DocumentUri ("file:///home/projects/TS/p1/f/content.ts" )
973+ thirdURI := lsproto .DocumentUri ("file:///home/projects/TS/p1/third.ts" )
974+ session .DidOpenFile (context .Background (), "file:///home/projects/TS/p1/index.ts" , 1 , files ["/home/projects/TS/p1/index.ts" ].(string ), lsproto .LanguageKindTypeScript )
975+ session .DidOpenFile (context .Background (), contentURI , 1 , files ["/home/projects/TS/p1/f/content.ts" ].(string ), lsproto .LanguageKindTypeScript )
976+
977+ _ , err := session .GetLanguageService (context .Background (), "file:///home/projects/TS/p1/index.ts" )
978+ assert .NilError (t , err )
979+ session .WaitForBackgroundTasks ()
980+
981+ baselineRefreshCount := len (utils .Client ().RefreshDiagnosticsCalls ())
982+
983+ err = utils .FS ().Remove ("/home/projects/TS/p1/f" )
984+ assert .NilError (t , err )
985+
986+ session .DidChangeWatchedFiles (context .Background (), []* lsproto.FileEvent {
987+ {
988+ Type : lsproto .FileChangeTypeDeleted ,
989+ Uri : "file:///home/projects/TS/p1/f" ,
990+ },
991+ })
992+ session .DidOpenFile (context .Background (), thirdURI , 1 , files ["/home/projects/TS/p1/third.ts" ].(string ), lsproto .LanguageKindTypeScript )
993+ session .WaitForBackgroundTasks ()
994+
995+ refreshCount := len (utils .Client ().RefreshDiagnosticsCalls ())
996+ assert .Assert (t , refreshCount > baselineRefreshCount ,
997+ "expected RefreshDiagnostics to be called after deleting /home/projects/TS/p1/f and opening /home/projects/TS/p1/third.ts, got %d calls (baseline %d)" ,
998+ refreshCount , baselineRefreshCount )
999+ })
1000+
9131001 t .Run ("create explicitly included file" , func (t * testing.T ) {
9141002 t .Parallel ()
9151003 files := map [string ]any {
0 commit comments