mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
fix: Fix reference autocompletions using incorrect offsets in macro inputs
Fixes https://github.com/rust-lang/rust-analyzer/issues/13035
This commit is contained in:
parent
dea163970a
commit
6c5d15800e
5 changed files with 41 additions and 16 deletions
|
@ -79,18 +79,18 @@ fn render(
|
|||
..ctx.completion_relevance()
|
||||
});
|
||||
|
||||
if let Some(ref_match) = compute_ref_match(completion, &ret_type) {
|
||||
match func_kind {
|
||||
FuncKind::Function(path_ctx) => {
|
||||
item.ref_match(ref_match, path_ctx.path.syntax().text_range().start());
|
||||
}
|
||||
FuncKind::Method(DotAccess { receiver: Some(receiver), .. }, _) => {
|
||||
if let Some(original_expr) = completion.sema.original_ast_node(receiver.clone()) {
|
||||
match func_kind {
|
||||
FuncKind::Function(path_ctx) => {
|
||||
super::path_ref_match(completion, path_ctx, &ret_type, &mut item);
|
||||
}
|
||||
FuncKind::Method(DotAccess { receiver: Some(receiver), .. }, _) => {
|
||||
if let Some(original_expr) = completion.sema.original_ast_node(receiver.clone()) {
|
||||
if let Some(ref_match) = compute_ref_match(completion, &ret_type) {
|
||||
item.ref_match(ref_match, original_expr.syntax().text_range().start());
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
item.set_documentation(ctx.docs(func))
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
use hir::{db::HirDatabase, Documentation, HasAttrs, StructKind};
|
||||
use ide_db::SymbolKind;
|
||||
use syntax::AstNode;
|
||||
|
||||
use crate::{
|
||||
context::{CompletionContext, PathCompletionCtx, PathKind},
|
||||
item::{Builder, CompletionItem},
|
||||
render::{
|
||||
compute_ref_match, compute_type_match,
|
||||
compute_type_match,
|
||||
variant::{
|
||||
format_literal_label, format_literal_lookup, render_record_lit, render_tuple_lit,
|
||||
visible_fields, RenderedLiteral,
|
||||
|
@ -125,9 +124,8 @@ fn render(
|
|||
type_match: compute_type_match(ctx.completion, &ty),
|
||||
..ctx.completion_relevance()
|
||||
});
|
||||
if let Some(ref_match) = compute_ref_match(completion, &ty) {
|
||||
item.ref_match(ref_match, path_ctx.path.syntax().text_range().start());
|
||||
}
|
||||
|
||||
super::path_ref_match(completion, path_ctx, &ty, &mut item);
|
||||
|
||||
if let Some(import_to_add) = ctx.import_to_add {
|
||||
item.add_import(import_to_add);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue