mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-14 00:47:18 +00:00
Auto merge of #17064 - Veykril:inlay-hints-fix, r=Veykril
minor: Carry inlay hint resolve hash as a string
This commit is contained in:
commit
f3c7bd0c90
4 changed files with 11 additions and 13 deletions
|
@ -1504,12 +1504,9 @@ pub(crate) fn handle_inlay_hints_resolve(
|
|||
) -> anyhow::Result<InlayHint> {
|
||||
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::<ide_db::FxHasher>::default(),
|
||||
hint,
|
||||
)
|
||||
// json only supports numbers up to 2^53 - 1 as integers, so mask the rest
|
||||
& ((1 << 53) - 1)
|
||||
},
|
||||
)?;
|
||||
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -453,8 +453,6 @@ pub(crate) fn inlay_hint(
|
|||
&std::hash::BuildHasherDefault::<FxHasher>::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,
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!---
|
||||
lsp/ext.rs hash: 4aacf4cca1c9ff5e
|
||||
lsp/ext.rs hash: dd51139b0530147e
|
||||
|
||||
If you need to change the above hash to make the test pass, please check if you
|
||||
need to adjust this doc as well and ping this issue:
|
||||
|
|
Loading…
Reference in a new issue