@@ -26,7 +26,18 @@ pub fn diagnostic<'doc>(
2626 Box::new(move |line: usize, _selected: bool, out: &mut String| {
2727 use helix_core::diagnostic::Severity;
2828 if let Ok(index) = diagnostics.binary_search_by_key(&line, |d| d.line) {
29− let diagnostic = &diagnostics[index];
29+ let after = diagnostics[index..].iter().take_while(|d| d.line == line);
30+
31+ let before = diagnostics[..index]
32+ .iter()
33+ .rev()
34+ .take_while(|d| d.line == line);
35+
36+ let diagnostics_on_line = after.chain(before);
37+
38+ // This unwrap is safe because the iterator cannot be empty as it contains at least the item found by the binary search.
39+ let diagnostic = diagnostics_on_line.max_by_key(|d| d.severity).unwrap();
40+
3041 write!(out, "●").unwrap();
3142 return Some(match diagnostic.severity {
3243 Some(Severity::Error) => error,