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)
) )
} }
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)