Skip to content

Commit e864320

Browse files
committed
Fix filesWithDiagnostics tracking for syntax-only errors
1 parent 7554adb commit e864320

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

server/src/server.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,12 +1011,34 @@ let updateDiagnosticSyntax = async (fileUri: string, fileContent: string) => {
10111011
tmpname,
10121012
]);
10131013

1014+
let allDiagnostics = [
1015+
...syntaxDiagnosticsForFile,
1016+
...compilerDiagnosticsForFile,
1017+
];
1018+
1019+
// Update filesWithDiagnostics to track this file
1020+
let projectRootPath = utils.findProjectRootOfFile(filePath);
1021+
if (projectRootPath != null) {
1022+
let projectFile = projectsFiles.get(projectRootPath);
1023+
if (projectFile != null) {
1024+
if (allDiagnostics.length > 0) {
1025+
projectFile.filesWithDiagnostics.add(fileUri);
1026+
} else {
1027+
// Only remove if there are no compiler diagnostics either
1028+
// (compiler diagnostics are tracked separately in filesDiagnostics)
1029+
if (compilerDiagnosticsForFile.length === 0) {
1030+
projectFile.filesWithDiagnostics.delete(fileUri);
1031+
}
1032+
}
1033+
}
1034+
}
1035+
10141036
let notification: p.NotificationMessage = {
10151037
jsonrpc: c.jsonrpcVersion,
10161038
method: "textDocument/publishDiagnostics",
10171039
params: {
10181040
uri: fileUri,
1019-
diagnostics: [...syntaxDiagnosticsForFile, ...compilerDiagnosticsForFile],
1041+
diagnostics: allDiagnostics,
10201042
},
10211043
};
10221044

0 commit comments

Comments
 (0)