@@ -642,7 +642,14 @@ export class TestControllerManager {
642642
643643 try {
644644 const o : { [ key : string ] : string } = { } ;
645- o [ document . fileName ] = document . getText ( ) ;
645+ for ( const document of vscode . workspace . textDocuments ) {
646+ if (
647+ SUPPORTED_LANGUAGES . includes ( document . languageId ) &&
648+ vscode . workspace . getWorkspaceFolder ( document . uri ) === folder
649+ ) {
650+ o [ document . fileName ] = document . getText ( ) ;
651+ }
652+ }
646653
647654 if ( this . diagnosticCollection . has ( document . uri ) ) {
648655 this . diagnosticCollection . delete ( document . uri ) ;
@@ -813,6 +820,10 @@ export class TestControllerManager {
813820 }
814821 } ) ;
815822 itemsToRemove . forEach ( ( i ) => {
823+ const item = this . testItems . get ( i ) ;
824+ if ( item !== undefined && item . canResolveChildren ) {
825+ this . removeNotAddedTestItems ( item , new Set < string > ( ) ) ;
826+ }
816827 items . delete ( i ) ;
817828 this . testItems . delete ( i ) ;
818829 } ) ;
@@ -864,8 +875,17 @@ export class TestControllerManager {
864875 }
865876
866877 private refreshUri ( uri ?: vscode . Uri , reason ?: string ) {
878+ this . outputChannel . appendLine ( `refresh uri ${ uri ? uri . toString ( ) : "unknown" } because: ${ reason ?? "unknown" } ` ) ;
879+
867880 if ( uri ) {
868- this . outputChannel . appendLine ( `refresh uri ${ uri . toString ( ) } ` ) ;
881+ const testItem = this . findTestItemByUri ( uri . toString ( ) ) ;
882+ if ( testItem ) {
883+ this . refreshItem ( testItem ) . then (
884+ ( _ ) => undefined ,
885+ ( _ ) => undefined
886+ ) ;
887+ return ;
888+ }
869889
870890 const workspace = vscode . workspace . getWorkspaceFolder ( uri ) ;
871891 if ( workspace === undefined ) return ;
0 commit comments