Skip to content

Commit 6c414a5

Browse files
committed
Don't create diagnostics with blank messages
1 parent 9e64c73 commit 6c414a5

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

server/src/utils.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -700,26 +700,31 @@ export let parseCompilerLogOutput = async (
700700
result[file] = [];
701701
}
702702

703-
let diagnostic: p.Diagnostic = {
704-
severity: parsedDiagnostic.severity,
705-
tags: parsedDiagnostic.tag === undefined ? [] : [parsedDiagnostic.tag],
706-
code: parsedDiagnostic.code,
707-
range,
708-
source: "ReScript",
709-
// remove start and end whitespaces/newlines
710-
message: diagnosticMessage.join("\n").trim(),
711-
};
703+
// remove start and end whitespaces/newlines
704+
let message = diagnosticMessage.join("\n").trim()
705+
706+
// vscode.Diagnostic throws an error if `message` is a blank string
707+
if (message != "") {
708+
let diagnostic: p.Diagnostic = {
709+
severity: parsedDiagnostic.severity,
710+
tags: parsedDiagnostic.tag === undefined ? [] : [parsedDiagnostic.tag],
711+
code: parsedDiagnostic.code,
712+
range,
713+
source: "ReScript",
714+
message,
715+
};
712716

713-
// Check for potential code actions
714-
await codeActions.findCodeActionsInDiagnosticsMessage({
715-
addFoundActionsHere: foundCodeActions,
716-
diagnostic,
717-
diagnosticMessage,
718-
file,
719-
range,
720-
});
717+
// Check for potential code actions
718+
await codeActions.findCodeActionsInDiagnosticsMessage({
719+
addFoundActionsHere: foundCodeActions,
720+
diagnostic,
721+
diagnosticMessage,
722+
file,
723+
range,
724+
});
721725

722-
result[file].push(diagnostic);
726+
result[file].push(diagnostic);
727+
}
723728
}
724729

725730
return {

0 commit comments

Comments
 (0)