diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index 9dd6dc999b..851341dfdf 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -1123,9 +1123,6 @@ pub(crate) fn handle_completion_resolve( return Ok(original_completion); }; let source_root = snap.analysis.source_root_id(file_id)?; - let Some(completion_hash_for_resolve) = &resolve_data.completion_item_hash else { - return Ok(original_completion); - }; let mut forced_resolve_completions_config = snap.config.completion(Some(source_root)); forced_resolve_completions_config.fields_to_resolve = CompletionFieldsToResolve::empty(); @@ -1142,7 +1139,7 @@ pub(crate) fn handle_completion_resolve( let Some(corresponding_completion) = completions.into_iter().find(|completion_item| { let hash = completion_item_hash(&completion_item, resolve_data.for_ref); - &hash == completion_hash_for_resolve + hash == resolve_data.hash }) else { return Ok(original_completion); }; diff --git a/crates/rust-analyzer/src/lsp/ext.rs b/crates/rust-analyzer/src/lsp/ext.rs index 7d60ae703b..afb9c909c6 100644 --- a/crates/rust-analyzer/src/lsp/ext.rs +++ b/crates/rust-analyzer/src/lsp/ext.rs @@ -827,7 +827,7 @@ pub struct CompletionResolveData { pub version: Option, pub trigger_character: Option, pub for_ref: bool, - pub completion_item_hash: Option<[u8; 20]>, + pub hash: [u8; 20], } #[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 97caed8f08..f70968d694 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -275,11 +275,7 @@ fn completion_item( completion_trigger_character: Option, item: CompletionItem, ) { - let original_completion_item = if fields_to_resolve == &CompletionFieldsToResolve::empty() { - None - } else { - Some(item.clone()) - }; + let original_completion_item = item.clone(); let insert_replace_support = config.insert_replace_support().then_some(tdpp.position); let ref_match = item.ref_match(); @@ -406,9 +402,7 @@ fn completion_item( version, trigger_character: completion_trigger_character, for_ref: true, - completion_item_hash: original_completion_item - .as_ref() - .map(|item| completion_item_hash(item, true)), + hash: completion_item_hash(&original_completion_item, true), }; Some(to_value(ref_resolve_data).unwrap()) } else { @@ -420,9 +414,7 @@ fn completion_item( version, trigger_character: completion_trigger_character, for_ref: false, - completion_item_hash: original_completion_item - .as_ref() - .map(|item| completion_item_hash(item, false)), + hash: completion_item_hash(&original_completion_item, false), }; (ref_resolve_data, Some(to_value(resolve_data).unwrap())) } else { diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 0086382517..80b35d453a 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@