Skip to content

Commit

Permalink
Fix missing upmapping in trait impls completion
Browse files Browse the repository at this point in the history
  • Loading branch information
ChayimFriedman2 committed Jan 19, 2025
1 parent 61af2cc commit 8b25ab0
Showing 1 changed file with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ pub(crate) fn complete_trait_impl_item_by_name(
acc,
ctx,
ImplCompletionKind::All,
match name_ref {
Some(name) => name.syntax().text_range(),
match name_ref
.as_ref()
.and_then(|name| ctx.sema.original_syntax_node_rooted(name.syntax()))
{
Some(name) => name.text_range(),
None => ctx.source_range(),
},
impl_,
Expand Down Expand Up @@ -516,7 +519,7 @@ fn function_declaration(
mod tests {
use expect_test::expect;

use crate::tests::{check_edit, check_no_kw};
use crate::tests::{check, check_edit, check_no_kw};

#[test]
fn no_completion_inside_fn() {
Expand Down Expand Up @@ -1639,4 +1642,31 @@ impl DesugaredAsyncTrait for () {
"#,
);
}

#[test]
fn within_attr_macro() {
check(
r#"
//- proc_macros: identity
trait Trait {
fn foo(&self) {}
fn bar(&self) {}
fn baz(&self) {}
}
#[proc_macros::identity]
impl Trait for () {
f$0
}
"#,
expect![[r#"
me fn bar(..)
me fn baz(..)
me fn foo(..)
md proc_macros
kw crate::
kw self::
"#]],
);
}
}

0 comments on commit 8b25ab0

Please sign in to comment.