Skip to content

Commit

Permalink
Fix crash with filtered diagnostics in gutter (e.g. when diagnostics …
Browse files Browse the repository at this point in the history
…aren't visible)
  • Loading branch information
Philipp-M committed May 18, 2023
1 parent 93fd79a commit 2a21b93
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions helix-view/src/gutter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,15 @@ 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();
return Some(match diagnostic.severity {
Some(Severity::Error) => error,
Some(Severity::Warning) | None => warning,
Some(Severity::Info) => info,
Some(Severity::Hint) => hint,
});
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,
Some(Severity::Info) => info,
Some(Severity::Hint) => hint,
});
}
}
None
},
Expand Down

0 comments on commit 2a21b93

Please sign in to comment.