Skip to content

Commit efcdc66

Browse files
authored
fix: refresh Test Explorer after first-time enable tests (#1870)
When the Test Explorer has no resolved projects yet and a `classpathUpdated` notification arrives (the exact scenario after "Java: Enable Tests" downloads a JUnit jar onto an unmanaged folder), `refreshProject` would iterate over zero items, match nothing and silently return, leaving the user to manually refresh. Root cause traced end-to-end via JDT-LS `.metadata/.log` and the LSP wire trace (`java.trace.server: verbose`): 1. jar lands in `lib/` 2. JDT-LS file watcher -> `UpdateClasspathJob` -> classpath delta (`>> Updating classpath` / `>> Adding <jar>`, both fire ~10x) 3. `ClasspathUpdateHandler` sends `language/eventNotification { eventType: 100, data: <ws-uri> }` 4. vscode-java fires `onDidClasspathUpdate(uri)` 5. vscode-java-test calls `refreshProject(uri)` 6. BUG: `testController.items.size === 0` -> no match -> silent return Fix the bootstrap case by falling back to a full `refreshExplorer()` when there are no roots to match against, while keeping the existing "skip unrelated classpath updates" behaviour intact for the common case where there ARE roots but the URI matches none of them (e.g. sibling non-test projects like Gradle's `buildSrc`).
1 parent 6133b3f commit efcdc66

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/commands/testExplorerCommands.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ export async function refreshProject(classpathUri: Uri): Promise<void> {
101101
});
102102
await Promise.all(loadPromises);
103103
} else {
104-
// URI doesn't match any known test project – skip to avoid unnecessary full refresh
104+
// Bootstrap: first-time enable tests on an empty Test Explorer.
105+
if (testController?.items.size === 0) {
106+
await refreshExplorer();
107+
}
105108
return;
106109
}
107110
await showTestItemsInCurrentFile();

0 commit comments

Comments
 (0)