Compare commits

...

2 Commits

Author SHA1 Message Date
538f3a322f Format code 2025-07-01 23:27:21 -04:00
ab4ebbe78a Fix to show backtraces of errors in other files 2025-07-01 23:27:00 -04:00

View File

@ -371,9 +371,7 @@ export function kclErrorsToDiagnostics(
sourceCode: string sourceCode: string
): CodeMirrorDiagnostic[] { ): CodeMirrorDiagnostic[] {
let nonFatal: CodeMirrorDiagnostic[] = [] let nonFatal: CodeMirrorDiagnostic[] = []
const errs = errors const errs = errors.flatMap((err) => {
?.filter((err) => isTopLevelModule(err.sourceRange))
.flatMap((err) => {
const diagnostics: CodeMirrorDiagnostic[] = [] const diagnostics: CodeMirrorDiagnostic[] = []
let message = err.msg let message = err.msg
if (err.kclBacktrace.length > 0) { if (err.kclBacktrace.length > 0) {
@ -410,12 +408,14 @@ export function kclErrorsToDiagnostics(
compilationErrorsToDiagnostics(err.nonFatal, sourceCode) compilationErrorsToDiagnostics(err.nonFatal, sourceCode)
) )
} }
if (isTopLevelModule(err.sourceRange)) {
diagnostics.push({ diagnostics.push({
from: toUtf16(err.sourceRange[0], sourceCode), from: toUtf16(err.sourceRange[0], sourceCode),
to: toUtf16(err.sourceRange[1], sourceCode), to: toUtf16(err.sourceRange[1], sourceCode),
message, message,
severity: 'error', severity: 'error',
}) })
}
return diagnostics return diagnostics
}) })
return errs.concat(nonFatal) return errs.concat(nonFatal)