mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Always compute the hash when r-a wants the imports to be resolved
This commit is contained in:
parent
62d97d9ba7
commit
d348ffb480
4 changed files with 6 additions and 17 deletions
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -827,7 +827,7 @@ pub struct CompletionResolveData {
|
|||
pub version: Option<i32>,
|
||||
pub trigger_character: Option<char>,
|
||||
pub for_ref: bool,
|
||||
pub completion_item_hash: Option<[u8; 20]>,
|
||||
pub hash: [u8; 20],
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
|
|
@ -275,11 +275,7 @@ fn completion_item(
|
|||
completion_trigger_character: Option<char>,
|
||||
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 {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!---
|
||||
lsp/ext.rs hash: 7d77940d7e63a8b
|
||||
lsp/ext.rs hash: c4c37ab0bcf7ccb0
|
||||
|
||||
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