Skip to content

Commit 91bd596

Browse files
committed
fix: make editing range accommodate for macros
1 parent 481fab1 commit 91bd596

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

crates/ide-diagnostics/src/handlers/unresolved_method.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use hir::{db::ExpandDatabase, AssocItem, HirDisplay};
1+
use hir::{db::ExpandDatabase, AssocItem, HirDisplay, InFile};
22
use ide_db::{
33
assists::{Assist, AssistId, AssistKind},
44
base_db::FileRange,
@@ -121,7 +121,9 @@ fn assoc_func_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedMethodCall) -
121121
let expr: ast::Expr = expr_ptr.value.to_node(&root);
122122

123123
let call = ast::MethodCallExpr::cast(expr.syntax().clone())?;
124-
let range = call.syntax().text_range();
124+
let range = InFile::new(expr_ptr.file_id, call.syntax().text_range())
125+
.original_node_file_range_rooted(db)
126+
.range;
125127

126128
let receiver = call.receiver()?;
127129
let receiver_type = &ctx.sema.type_of_expr(&receiver)?.original;
@@ -241,7 +243,7 @@ impl A {
241243
fn main() {
242244
let a = A{};
243245
a.hello();
244-
// ^^^^^^^^^ 💡 error: no method `hello` on type `A`, but an associated function with a similar name exists
246+
// ^^^^^ 💡 error: no method `hello` on type `A`, but an associated function with a similar name exists
245247
}
246248
"#,
247249
);

0 commit comments

Comments
 (0)