From cafec867f1f52f095a613d59f79a1ee8b05c1038 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 16 Feb 2017 19:51:36 +0400 Subject: [PATCH] Fixed diagnostics (#89) --- src/components/cargo/diagnostic_parser.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/cargo/diagnostic_parser.ts b/src/components/cargo/diagnostic_parser.ts index 046fba0..681e45c 100644 --- a/src/components/cargo/diagnostic_parser.ts +++ b/src/components/cargo/diagnostic_parser.ts @@ -115,7 +115,11 @@ export class DiagnosticParser { message = `${compilerMessage.code.code}: ${message}`; } - this.addNotesToMessage(message, compilerMessage.children, 1); + if (primarySpan.label) { + message += `\n label: ${primarySpan.label}`; + } + + message = this.addNotesToMessage(message, compilerMessage.children, 1); const diagnostic = new Diagnostic(range, message, this.toSeverity(compilerMessage.level)); @@ -141,10 +145,10 @@ export class DiagnosticParser { } private addNotesToMessage(msg: string, children: any[], level: number): string { - const ident = ' '.repeat(level); + const indentation = ' '.repeat(level); for (const child of children) { - msg += `\n${ident}${child.message}`; + msg += `\n${indentation}${child.level}: ${child.message}`; if (child.spans && child.spans.length > 0) { msg += ': ';