From 77c5899bbd7c46733ea208a7506c1d07b773bc2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Wed, 22 Sep 2021 13:13:52 -0700 Subject: [PATCH] fix(graphical): render URLs even without a code --- src/handlers/graphical.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/handlers/graphical.rs b/src/handlers/graphical.rs index e2c6074..ae12a4d 100644 --- a/src/handlers/graphical.rs +++ b/src/handlers/graphical.rs @@ -123,19 +123,18 @@ impl GraphicalReportHandler { Some(Severity::Advice) => self.theme.styles.advice, }; let mut header = String::new(); - if self.linkify_code && diagnostic.url().is_some() && diagnostic.code().is_some() { + if self.linkify_code && diagnostic.url().is_some() { let url = diagnostic.url().unwrap(); // safe - let code = format!( - "{}", - diagnostic - .code() - .expect("MIETTE BUG: already got checked for None") - ); + let code = if let Some(code) = diagnostic.code() { + format!("{} ", code) + } else { + "".to_string() + }; let link = format!( "\u{1b}]8;;{}\u{1b}\\{}\u{1b}]8;;\u{1b}\\", url, format!( - "{} {}", + "{}{}", code.style(severity_style), "(link)".style(self.theme.styles.link) )