Fix a case where completion was unable to expand a macro

Which caused the macros of the popular `tracing` crate to not offer completions.

The reason is rather complicated: it boils down to macro ignoring their input and completion always choosing the first expansion.
This commit is contained in:
Chayim Refael Friedman 2024-12-20 02:27:37 +02:00
parent e0c11f631e
commit 02d47f3a81
16 changed files with 604 additions and 368 deletions

View file

@ -718,7 +718,7 @@ impl<'a> CompletionContext<'a> {
expected: (expected_type, expected_name),
qualifier_ctx,
token,
offset,
original_offset,
} = expand_and_analyze(
&sema,
original_file.syntax().clone(),
@ -728,7 +728,7 @@ impl<'a> CompletionContext<'a> {
)?;
// adjust for macro input, this still fails if there is no token written yet
let scope = sema.scope_at_offset(&token.parent()?, offset)?;
let scope = sema.scope_at_offset(&token.parent()?, original_offset)?;
let krate = scope.krate();
let module = scope.module();