From af7a1fd20c0a2915e0dae1b5bea7cb6bde6c2746 Mon Sep 17 00:00:00 2001 From: Lennard Hofmann Date: Sun, 25 Aug 2024 21:27:10 +0200 Subject: [PATCH] lsp: Gracefully ignore invalid diagnostic severity (#11569) --- helix-view/src/document.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 15aa81da..91ec2787 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -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 {