fix: Fix hover in attributed items not preferring similar kinded tokens

This commit is contained in:
Lukas Wirth 2022-11-11 13:38:07 +01:00
parent 599142c34a
commit e50712cf2c

View File

@ -119,7 +119,14 @@ pub(crate) fn hover(
}); });
} }
let in_attr = matches!(original_token.parent().and_then(ast::TokenTree::cast), Some(tt) if tt.syntax().ancestors().any(|it| ast::Meta::can_cast(it.kind()))); let in_attr = original_token
.parent_ancestors()
.filter_map(ast::Item::cast)
.any(|item| sema.is_attr_macro_call(&item))
&& !matches!(
original_token.parent().and_then(ast::TokenTree::cast),
Some(tt) if tt.syntax().ancestors().any(|it| ast::Meta::can_cast(it.kind()))
);
// prefer descending the same token kind in attribute expansions, in normal macros text // prefer descending the same token kind in attribute expansions, in normal macros text
// equivalency is more important // equivalency is more important
let descended = if in_attr { let descended = if in_attr {