Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Resolve proto hints with empty resolve data (#19274)

Kirill Bulatov02f63e49ed1f
diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rs
index 96eb327e8c4..4a80180d7cd 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::<Option<lsp::LSPAny>>(&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::<Option<lsp::LSPAny>>(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 750aa924b4f..822ccf6cf71 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;
}
}