diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index 3439ae1d07..c99b22bb7d 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -1504,12 +1504,9 @@ pub(crate) fn handle_inlay_hints_resolve( ) -> anyhow::Result { let _p = tracing::span!(tracing::Level::INFO, "handle_inlay_hints_resolve").entered(); - let data = match original_hint.data.take() { - Some(it) => it, - None => return Ok(original_hint), - }; - + let Some(data) = original_hint.data.take() else { return Ok(original_hint) }; let resolve_data: lsp_ext::InlayHintResolveData = serde_json::from_value(data)?; + let Some(hash) = resolve_data.hash.parse().ok() else { return Ok(original_hint) }; let file_id = FileId::from_raw(resolve_data.file_id); anyhow::ensure!(snap.file_exists(file_id), "Invalid LSP resolve data"); @@ -1521,14 +1518,12 @@ pub(crate) fn handle_inlay_hints_resolve( &forced_resolve_inlay_hints_config, file_id, hint_position, - resolve_data.hash, + hash, |hint| { std::hash::BuildHasher::hash_one( &std::hash::BuildHasherDefault::::default(), hint, ) - // json only supports numbers up to 2^53 - 1 as integers, so mask the rest - & ((1 << 53) - 1) }, )?; diff --git a/crates/rust-analyzer/src/lsp/ext.rs b/crates/rust-analyzer/src/lsp/ext.rs index 1ef49b5c11..12f8e71c98 100644 --- a/crates/rust-analyzer/src/lsp/ext.rs +++ b/crates/rust-analyzer/src/lsp/ext.rs @@ -794,7 +794,8 @@ pub struct CompletionResolveData { #[derive(Debug, Serialize, Deserialize)] pub struct InlayHintResolveData { pub file_id: u32, - pub hash: u64, + // This is a string instead of a u64 as javascript can't represent u64 fully + pub hash: String, } #[derive(Debug, Serialize, Deserialize)] diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs index 04a5486e94..2688c8ce0d 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -453,8 +453,6 @@ pub(crate) fn inlay_hint( &std::hash::BuildHasherDefault::::default(), &inlay_hint, ) - // json only supports numbers up to 2^53 - 1 as integers, so mask the rest - & ((1 << 53) - 1) }); let mut something_to_resolve = false; @@ -481,7 +479,11 @@ pub(crate) fn inlay_hint( let data = match resolve_hash { Some(hash) if something_to_resolve => Some( - to_value(lsp_ext::InlayHintResolveData { file_id: file_id.index(), hash }).unwrap(), + to_value(lsp_ext::InlayHintResolveData { + file_id: file_id.index(), + hash: hash.to_string(), + }) + .unwrap(), ), _ => None, }; diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 1b7534a549..f1815082e2 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@