diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rs index f1f2ca5bd636a..9760ce6530c6d 100644 --- a/crates/project/src/lsp_command.rs +++ b/crates/project/src/lsp_command.rs @@ -3044,7 +3044,7 @@ impl LspCommand for LinkedEditingRange { #[async_trait(?Send)] impl LspCommand for GetDocumentDiagnostics { - type Response = Vec; + type Response = Option>; type LspRequest = lsp::request::DocumentDiagnosticRequest; type ProtoRequest = proto::GetDocumentDiagnostics; @@ -3088,15 +3088,15 @@ impl LspCommand for GetDocumentDiagnostics { _: Model, _: LanguageServerId, _: AsyncAppContext, - ) -> Result> { + ) -> Result { match message { lsp::DocumentDiagnosticReportResult::Report(report) => match report { lsp::DocumentDiagnosticReport::Full(report) => { - Ok(report.full_document_diagnostic_report.items.clone()) + Ok(Some(report.full_document_diagnostic_report.items.clone())) } - lsp::DocumentDiagnosticReport::Unchanged(_) => Ok(vec![]), + lsp::DocumentDiagnosticReport::Unchanged(_) => Ok(None), }, - lsp::DocumentDiagnosticReportResult::Partial(_) => Ok(vec![]), + lsp::DocumentDiagnosticReportResult::Partial(_) => Ok(None), } } @@ -3130,7 +3130,7 @@ impl LspCommand for GetDocumentDiagnostics { } fn response_to_proto( - _: Vec, + _: Self::Response, _: &mut LspStore, _: PeerId, _: &clock::Global, @@ -3145,7 +3145,7 @@ impl LspCommand for GetDocumentDiagnostics { _: Model, _: Model, _: AsyncAppContext, - ) -> Result> { + ) -> Result { todo!() } diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index d692b3458a940..e172c59681bd7 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -809,6 +809,7 @@ impl LspStore { client.add_model_request_handler(Self::handle_lsp_command::); client.add_model_request_handler(Self::handle_lsp_command::); client.add_model_request_handler(Self::handle_lsp_command::); + client.add_model_request_handler(Self::handle_lsp_command::); } pub fn as_remote(&self) -> Option<&RemoteLspStore> { @@ -3195,23 +3196,25 @@ impl LspStore { Ok(diagnostics .into_iter() - .collect::>>>()? + .collect::>>()? .into_iter() - .flatten() + .flat_map(|diagnostics| diagnostics.into_iter().flatten()) .collect()) }) } else { let all_actions_task = self.request_multiple_lsp_locally( buffer_handle, Some(position), - GetDocumentDiagnostics { - position: position.clone(), - }, + GetDocumentDiagnostics { position }, cx, ); - cx.spawn( - |_, _| async move { Ok(all_actions_task.await.into_iter().flatten().collect()) }, - ) + cx.spawn(|_, _| async move { + Ok(all_actions_task + .await + .into_iter() + .flat_map(|diagnostics| diagnostics.into_iter().flatten()) + .collect()) + }) } }