fix(graphical): render URLs even without a code

This commit is contained in:
Kat Marchán 2021-09-22 13:13:52 -07:00
parent ce0dea541a
commit 77c5899bbd
1 changed files with 7 additions and 8 deletions

View File

@ -123,19 +123,18 @@ impl GraphicalReportHandler {
Some(Severity::Advice) => self.theme.styles.advice, Some(Severity::Advice) => self.theme.styles.advice,
}; };
let mut header = String::new(); 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 url = diagnostic.url().unwrap(); // safe
let code = format!( let code = if let Some(code) = diagnostic.code() {
"{}", format!("{} ", code)
diagnostic } else {
.code() "".to_string()
.expect("MIETTE BUG: already got checked for None") };
);
let link = format!( let link = format!(
"\u{1b}]8;;{}\u{1b}\\{}\u{1b}]8;;\u{1b}\\", "\u{1b}]8;;{}\u{1b}\\{}\u{1b}]8;;\u{1b}\\",
url, url,
format!( format!(
"{} {}", "{}{}",
code.style(severity_style), code.style(severity_style),
"(link)".style(self.theme.styles.link) "(link)".style(self.theme.styles.link)
) )