fix(daemon): clear diagnostics and reload TypeScript projects on watcher events

Evicting the entire entry on derived watcher events was overly aggressive.
Instead, clear cached diagnostics and send a reloadProjects command to the
TypeScript language server so it picks up workspace changes without losing
state.
This commit is contained in:
2026-05-24 11:57:01 -04:00
parent 071c87d3c1
commit 8cfe604de7

View File

@@ -191,11 +191,15 @@ function forwardEvents(entry: ClientEntry, events: FileEvent[]): void {
if (process.env.LSP_DEBUG) {
log(`watcher fire`, entry.server.id, JSON.stringify(events));
}
for (const uri of entry.opened.keys()) entry.client.clearDiagnostics(uri);
entry.client.sendNotification("workspace/didChangeWatchedFiles", {
changes: events,
});
if (entry.usesDerivedWatchers) {
evict(entry, "derived watcher event");
if (entry.usesDerivedWatchers && entry.server.id === "typescript-language-server") {
void entry.client.sendRequest("workspace/executeCommand", {
command: "typescript.tsserverRequest",
arguments: ["reloadProjects"],
}).catch((err) => log("typescript reloadProjects failed", (err as Error).message));
}
} catch (err) {
log(`watcher send failed`, entry.server.id, (err as Error).message);