Skip to content

Commit f77e6dd

Browse files
committed
Make server.sendUpdatedDiagnostics async
1 parent d729e3a commit f77e6dd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

server/src/server.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ let getCurrentCompilerDiagnosticsForFile = (
9292

9393
return diagnostics ?? [];
9494
};
95-
let sendUpdatedDiagnostics = () => {
96-
projectsFiles.forEach((projectFile, projectRootPath) => {
95+
96+
let sendUpdatedDiagnostics = async () => {
97+
for (const [projectRootPath, projectFile] of projectsFiles) {
9798
let { filesWithDiagnostics } = projectFile;
9899
let compilerLogPath = path.join(projectRootPath, c.compilerLogPartialPath);
99100
let content = fs.readFileSync(compilerLogPath, { encoding: "utf-8" });
@@ -154,8 +155,9 @@ let sendUpdatedDiagnostics = () => {
154155
}
155156
});
156157
}
157-
});
158+
}
158159
};
160+
159161
let deleteProjectDiagnostics = (projectRootPath: string) => {
160162
let root = projectsFiles.get(projectRootPath);
161163
if (root != null) {
@@ -178,6 +180,7 @@ let deleteProjectDiagnostics = (projectRootPath: string) => {
178180
}
179181
}
180182
};
183+
181184
let sendCompilationFinishedMessage = () => {
182185
let notification: p.NotificationMessage = {
183186
jsonrpc: c.jsonrpcVersion,
@@ -215,7 +218,7 @@ let compilerLogsWatcher = chokidar
215218
stabilityThreshold: 1,
216219
},
217220
})
218-
.on("all", (_e, changedPath) => {
221+
.on("all", async (_e, changedPath) => {
219222
if (changedPath.includes("build.ninja")) {
220223
if (config.extensionConfiguration.cache?.projectConfig?.enable === true) {
221224
let projectRoot = utils.findProjectRootOfFile(changedPath);
@@ -225,7 +228,7 @@ let compilerLogsWatcher = chokidar
225228
}
226229
} else {
227230
try {
228-
sendUpdatedDiagnostics();
231+
await sendUpdatedDiagnostics();
229232
sendCompilationFinishedMessage();
230233
if (config.extensionConfiguration.inlayHints?.enable === true) {
231234
sendInlayHintsRefresh();

0 commit comments

Comments
 (0)