Fix crash with filtered diagnostics in gutter (e.g. when diagnostics aren't visible)
This commit is contained in:
parent
93fd79a949
commit
2a21b939c4
1 changed files with 9 additions and 10 deletions
|
@ -83,10 +83,8 @@ pub fn diagnostic<'doc>(
|
|||
|
||||
let diagnostics_on_line = after.chain(before);
|
||||
|
||||
// This unwrap is safe because the iterator cannot be empty as it contains at least the item found by the binary search.
|
||||
let diagnostic = diagnostics_on_line.max_by_key(|d| d.severity).unwrap();
|
||||
|
||||
write!(out, "●").unwrap();
|
||||
if let Some(diagnostic) = diagnostics_on_line.max_by_key(|d| d.severity) {
|
||||
write!(out, "●").ok();
|
||||
return Some(match diagnostic.severity {
|
||||
Some(Severity::Error) => error,
|
||||
Some(Severity::Warning) | None => warning,
|
||||
|
@ -94,6 +92,7 @@ pub fn diagnostic<'doc>(
|
|||
Some(Severity::Hint) => hint,
|
||||
});
|
||||
}
|
||||
}
|
||||
None
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue