Auto merge of #12475 - Veykril:trait-impl-completion, r=Veykril

fix: Fix trait impl completions using wrong insert position

Fixes https://github.com/rust-lang/rust-analyzer/issues/12474
This commit is contained in:
bors 2022-06-05 18:29:59 +00:00
commit ad6810e90b

View file

@ -118,7 +118,7 @@ fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, Text
ImplCompletionKind::All,
match nameref {
Some(name) => name.syntax().text_range(),
None => TextRange::empty(ctx.position.offset),
None => ctx.source_range(),
},
ctx.impl_def.clone()?,
)),
@ -688,6 +688,27 @@ trait Test {
type SomeType;
}
impl Test for () {
type SomeType = $0;\n\
}
",
);
check_edit(
"type SomeType",
r#"
trait Test {
type SomeType;
}
impl Test for () {
type$0
}
"#,
"
trait Test {
type SomeType;
}
impl Test for () {
type SomeType = $0;\n\
}