Always compute the hash when r-a wants the imports to be resolved

This commit is contained in:
Kirill Bulatov 2024-12-09 22:09:25 +02:00
parent 62d97d9ba7
commit d348ffb480
4 changed files with 6 additions and 17 deletions

View file

@ -1123,9 +1123,6 @@ pub(crate) fn handle_completion_resolve(
return Ok(original_completion); return Ok(original_completion);
}; };
let source_root = snap.analysis.source_root_id(file_id)?; 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)); let mut forced_resolve_completions_config = snap.config.completion(Some(source_root));
forced_resolve_completions_config.fields_to_resolve = CompletionFieldsToResolve::empty(); 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 Some(corresponding_completion) = completions.into_iter().find(|completion_item| {
let hash = completion_item_hash(&completion_item, resolve_data.for_ref); let hash = completion_item_hash(&completion_item, resolve_data.for_ref);
&hash == completion_hash_for_resolve hash == resolve_data.hash
}) else { }) else {
return Ok(original_completion); return Ok(original_completion);
}; };

View file

@ -827,7 +827,7 @@ pub struct CompletionResolveData {
pub version: Option<i32>, pub version: Option<i32>,
pub trigger_character: Option<char>, pub trigger_character: Option<char>,
pub for_ref: bool, pub for_ref: bool,
pub completion_item_hash: Option<[u8; 20]>, pub hash: [u8; 20],
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]

View file

@ -275,11 +275,7 @@ fn completion_item(
completion_trigger_character: Option<char>, completion_trigger_character: Option<char>,
item: CompletionItem, item: CompletionItem,
) { ) {
let original_completion_item = if fields_to_resolve == &CompletionFieldsToResolve::empty() { let original_completion_item = item.clone();
None
} else {
Some(item.clone())
};
let insert_replace_support = config.insert_replace_support().then_some(tdpp.position); let insert_replace_support = config.insert_replace_support().then_some(tdpp.position);
let ref_match = item.ref_match(); let ref_match = item.ref_match();
@ -406,9 +402,7 @@ fn completion_item(
version, version,
trigger_character: completion_trigger_character, trigger_character: completion_trigger_character,
for_ref: true, for_ref: true,
completion_item_hash: original_completion_item hash: completion_item_hash(&original_completion_item, true),
.as_ref()
.map(|item| completion_item_hash(item, true)),
}; };
Some(to_value(ref_resolve_data).unwrap()) Some(to_value(ref_resolve_data).unwrap())
} else { } else {
@ -420,9 +414,7 @@ fn completion_item(
version, version,
trigger_character: completion_trigger_character, trigger_character: completion_trigger_character,
for_ref: false, for_ref: false,
completion_item_hash: original_completion_item hash: completion_item_hash(&original_completion_item, false),
.as_ref()
.map(|item| completion_item_hash(item, false)),
}; };
(ref_resolve_data, Some(to_value(resolve_data).unwrap())) (ref_resolve_data, Some(to_value(resolve_data).unwrap()))
} else { } else {

View file

@ -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 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: need to adjust this doc as well and ping this issue: