Fix to show backtraces of errors in other files

This commit is contained in:
Jonathan Tran
2025-07-01 23:25:24 -04:00
parent fba62dab98
commit ab4ebbe78a

View File

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