From 02f63e49ed1fb9a890f736fdc8f00540ccf46eb6 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 16 Oct 2024 21:50:51 +0300 Subject: [PATCH] Resolve proto hints with empty resolve data (#19274) Fixed ssh remoting not showing a lot of hints Release Notes: - N/A --- crates/project/src/lsp_command.rs | 18 +++++++++--------- crates/proto/proto/zed.proto | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rs index 96eb327e8c..4a80180d7c 100644 --- a/crates/project/src/lsp_command.rs +++ b/crates/project/src/lsp_command.rs @@ -2439,15 +2439,13 @@ impl InlayHints { ResolveState::Resolved => (0, None), ResolveState::CanResolve(server_id, resolve_data) => ( 1, - resolve_data - .map(|json_data| { + Some(proto::resolve_state::LspResolveState { + server_id: server_id.0 as u64, + value: resolve_data.map(|json_data| { serde_json::to_string(&json_data) .expect("failed to serialize resolve json data") - }) - .map(|value| proto::resolve_state::LspResolveState { - server_id: server_id.0 as u64, - value, }), + }), ), ResolveState::Resolving => (2, None), }; @@ -2515,9 +2513,11 @@ impl InlayHints { let resolve_state_data = resolve_state .lsp_resolve_state.as_ref() .map(|lsp_resolve_state| { - serde_json::from_str::>(&lsp_resolve_state.value) - .with_context(|| format!("incorrect proto inlay hint message: non-json resolve state {lsp_resolve_state:?}")) - .map(|state| (LanguageServerId(lsp_resolve_state.server_id as usize), state)) + let value = lsp_resolve_state.value.as_deref().map(|value| { + serde_json::from_str::>(value) + .with_context(|| format!("incorrect proto inlay hint message: non-json resolve state {lsp_resolve_state:?}")) + }).transpose()?.flatten(); + anyhow::Ok((LanguageServerId(lsp_resolve_state.server_id as usize), value)) }) .transpose()?; let resolve_state = match resolve_state.state { diff --git a/crates/proto/proto/zed.proto b/crates/proto/proto/zed.proto index 750aa924b4..822ccf6cf7 100644 --- a/crates/proto/proto/zed.proto +++ b/crates/proto/proto/zed.proto @@ -1207,7 +1207,7 @@ message ResolveState { } message LspResolveState { - string value = 1; + optional string value = 1; uint64 server_id = 2; } }