diff --git a/server/src/server.ts b/server/src/server.ts index c7e0cf2c0..12e1c1948 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -216,17 +216,43 @@ let compilerLogsWatcher = chokidar stabilityThreshold: 1, }, }) - .on("all", (_e, changedPath) => { + .on("all", (eventName, changedPath, stats) => { + console.log(eventName, changedPath, stats); if (changedPath.includes("build.ninja")) { if (config.extensionConfiguration.cache?.projectConfig?.enable === true) { + console.log("Changed path includes build ninja"); let projectRoot = utils.findProjectRootOfFile(changedPath); if (projectRoot != null) { + console.log("Sync project config cache"); + syncProjectConfigCache(projectRoot); + } + } + } else if ( + eventName === "unlink" && + changedPath.includes(".compiler.log") + ) { + console.log(compilerLogsWatcher.getWatched()); + console.log(".compiler.log has been deleted"); + + let projectRoot = utils.findProjectRootOfFile(changedPath); + if (projectRoot != null) { + compilerLogsWatcher.add( + path.join(projectRoot, c.compilerLogPartialPath) + ); + if ( + config.extensionConfiguration.cache?.projectConfig?.enable === true + ) { + compilerLogsWatcher.add( + path.join(projectRoot, c.buildNinjaPartialPath) + ); syncProjectConfigCache(projectRoot); } } } else { try { + console.log("Send updated diagnostics"); sendUpdatedDiagnostics(); + console.log("Send compilation finished message"); sendCompilationFinishedMessage(); if (config.extensionConfiguration.inlayHints?.enable === true) { sendInlayHintsRefresh(); @@ -234,12 +260,13 @@ let compilerLogsWatcher = chokidar if (config.extensionConfiguration.codeLens === true) { sendCodeLensRefresh(); } - } catch { - console.log("Error while sending updated diagnostics"); + } catch (error) { + console.log("Error while sending updated diagnostics", error); } } }); let stopWatchingCompilerLog = () => { + console.log("Stop watching compiler log"); // TODO: cleanup of compilerLogs? compilerLogsWatcher.close(); };