Dont create empty diagnostic messages #1114
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
VS Code throws a
TypeError: message not sent
error if a diagnostic message is blank:https://github.com/microsoft/vscode/blob/3aef8be5e46aa7e97e8b0ed115f6147cd0b24634/src/vs/workbench/api/common/extHostTypes.ts#L1183-L1185
We create diagnostics with empty messages if
diagnosticMessage
is an empty array, which happens ifparsedDiagnostic.content
is empty or has only 1 element:rescript-vscode/server/src/utils.ts
Lines 699 to 707 in ef518a9
The compiler log message
FAILED: cannot make progress due to previous errors.
is converted to a diagnostic message withcontent: [line]
, which triggers this condition:rescript-vscode/server/src/utils.ts
Lines 571 to 578 in 5b76419
In addition to adding a check for
message != ""
before creating a diagnostic message, I've also changed the compiler log output parser to skip the following errors messages:FAILED: cannot make progress due to previous errors
FAILED: dependency cycle
These errors don't currently contain filepath/range information and so we cannot create diagnostic messages for them anyway (though with some tweaking on the compiler side, we might be able to output filepaths for dependency cycle errors.)