diff --git a/CHANGELOG.md b/CHANGELOG.md index 876eebbff..02d8624fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,9 +19,11 @@ #### :bug: Bug fix +- Fix: Dont create empty diagnostic messages. https://github.com/rescript-lang/rescript-vscode/pull/1114 + - Fix: `rescript-editor-analysis.exe semanticTokens` sometimes returned invalid JSON, which affected syntax highlighting. https://github.com/rescript-lang/rescript-vscode/pull/1113 - - Fix: hang in `rescript-editor-analysis.exe codeAction` that sometimes prevented ReScript files from being saved in VS Code. https://github.com/rescript-lang/rescript-vscode/pull/1112 +- Fix: hang in `rescript-editor-analysis.exe codeAction` that sometimes prevented ReScript files from being saved in VS Code. https://github.com/rescript-lang/rescript-vscode/pull/1112 - Fix: show existing compiler errors and warnings on file open. https://github.com/rescript-lang/rescript-vscode/pull/1103 diff --git a/server/src/utils.ts b/server/src/utils.ts index ae2639252..e961ca23b 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -568,8 +568,11 @@ export let parseCompilerLogOutput = async ( tag: undefined, content: [], }); + } else if (line.startsWith("FAILED: cannot make progress due to previous errors.")) { + // skip + } else if (line.startsWith("FAILED: dependency cycle")) { + // skip as we can't extract a filepath from this error message } else if (line.startsWith("FAILED:")) { - // File with a self cycle parsedDiagnostics.push({ code: undefined, severity: t.DiagnosticSeverity.Error, @@ -700,26 +703,31 @@ export let parseCompilerLogOutput = async ( result[file] = []; } - let diagnostic: p.Diagnostic = { - severity: parsedDiagnostic.severity, - tags: parsedDiagnostic.tag === undefined ? [] : [parsedDiagnostic.tag], - code: parsedDiagnostic.code, - range, - source: "ReScript", - // remove start and end whitespaces/newlines - message: diagnosticMessage.join("\n").trim(), - }; + // remove start and end whitespaces/newlines + let message = diagnosticMessage.join("\n").trim() + + // vscode.Diagnostic throws an error if `message` is a blank string + if (message != "") { + let diagnostic: p.Diagnostic = { + severity: parsedDiagnostic.severity, + tags: parsedDiagnostic.tag === undefined ? [] : [parsedDiagnostic.tag], + code: parsedDiagnostic.code, + range, + source: "ReScript", + message, + }; - // Check for potential code actions - await codeActions.findCodeActionsInDiagnosticsMessage({ - addFoundActionsHere: foundCodeActions, - diagnostic, - diagnosticMessage, - file, - range, - }); + // Check for potential code actions + await codeActions.findCodeActionsInDiagnosticsMessage({ + addFoundActionsHere: foundCodeActions, + diagnostic, + diagnosticMessage, + file, + range, + }); - result[file].push(diagnostic); + result[file].push(diagnostic); + } } return {