From 6c414a57352c8e8e72a3aba49f4261ecc6c64302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Sat, 2 Aug 2025 13:08:25 +0200 Subject: [PATCH 1/5] Don't create diagnostics with blank messages --- server/src/utils.ts | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/server/src/utils.ts b/server/src/utils.ts index ae2639252..d01efbd9e 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -700,26 +700,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 { From c38fdf54f19408b53754baa748885b0203bb5fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Sat, 2 Aug 2025 14:42:42 +0200 Subject: [PATCH 2/5] Don't attempt to create diagnostic message for compiler log line 'cannot make progress due to previous errors' --- server/src/utils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/utils.ts b/server/src/utils.ts index d01efbd9e..7ca596249 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -568,6 +568,8 @@ 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:")) { // File with a self cycle parsedDiagnostics.push({ From ef518a9ae69caf1b398204eaddf13517aa82ae3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Sat, 2 Aug 2025 14:54:44 +0200 Subject: [PATCH 3/5] Don't attempt to create diagnostic message for dependency cycle error --- server/src/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/utils.ts b/server/src/utils.ts index 7ca596249..e961ca23b 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -570,8 +570,9 @@ export let parseCompilerLogOutput = async ( }); } 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, From 9989204499b182b390abdc79499e776385e00b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Sat, 2 Aug 2025 15:23:07 +0200 Subject: [PATCH 4/5] Add CHANGELOG entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 876eebbff..a873ba753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ #### :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 From 067087e0c08a1086c3bb52aa0a5f73bd727447b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Sat, 2 Aug 2025 15:23:37 +0200 Subject: [PATCH 5/5] Remove extra space before CHANGELOG entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a873ba753..02d8624fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ - 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