Skip to content

Commit

Permalink
lsp: Gracefully ignore invalid diagnostic severity (#11569)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ordoviz authored Aug 25, 2024
1 parent 620dfce commit af7a1fd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1920,12 +1920,15 @@ impl Document {
return None;
};

let severity = diagnostic.severity.map(|severity| match severity {
lsp::DiagnosticSeverity::ERROR => Error,
lsp::DiagnosticSeverity::WARNING => Warning,
lsp::DiagnosticSeverity::INFORMATION => Info,
lsp::DiagnosticSeverity::HINT => Hint,
severity => unreachable!("unrecognized diagnostic severity: {:?}", severity),
let severity = diagnostic.severity.and_then(|severity| match severity {
lsp::DiagnosticSeverity::ERROR => Some(Error),
lsp::DiagnosticSeverity::WARNING => Some(Warning),
lsp::DiagnosticSeverity::INFORMATION => Some(Info),
lsp::DiagnosticSeverity::HINT => Some(Hint),
severity => {
log::error!("unrecognized diagnostic severity: {:?}", severity);
None
}
});

if let Some(lang_conf) = language_config {
Expand Down

0 comments on commit af7a1fd

Please sign in to comment.