diff options
Diffstat (limited to 'cli/lsp/diagnostics.rs')
-rw-r--r-- | cli/lsp/diagnostics.rs | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index f720299d7..d4ec3d494 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -461,31 +461,27 @@ fn get_diagnostic_message(diagnostic: &diagnostics::Diagnostic) -> String { fn to_lsp_related_information( related_information: &Option<Vec<diagnostics::Diagnostic>>, ) -> Option<Vec<lsp::DiagnosticRelatedInformation>> { - if let Some(related) = related_information { - Some( - related - .iter() - .filter_map(|ri| { - if let (Some(source), Some(start), Some(end)) = - (&ri.source, &ri.start, &ri.end) - { - let uri = lsp::Url::parse(&source).unwrap(); - Some(lsp::DiagnosticRelatedInformation { - location: lsp::Location { - uri, - range: to_lsp_range(start, end), - }, - message: get_diagnostic_message(&ri), - }) - } else { - None - } - }) - .collect(), - ) - } else { - None - } + related_information.as_ref().map(|related| { + related + .iter() + .filter_map(|ri| { + if let (Some(source), Some(start), Some(end)) = + (&ri.source, &ri.start, &ri.end) + { + let uri = lsp::Url::parse(&source).unwrap(); + Some(lsp::DiagnosticRelatedInformation { + location: lsp::Location { + uri, + range: to_lsp_range(start, end), + }, + message: get_diagnostic_message(&ri), + }) + } else { + None + } + }) + .collect() + }) } fn ts_json_to_diagnostics( |