]> git.lizzy.rs Git - rust.git/commitdiff
fix: Fix trait impl completions using wrong insert position
authorLukas Wirth <lukastw97@gmail.com>
Sun, 5 Jun 2022 18:29:36 +0000 (20:29 +0200)
committerLukas Wirth <lukastw97@gmail.com>
Sun, 5 Jun 2022 18:29:36 +0000 (20:29 +0200)
crates/ide-completion/src/completions/item_list/trait_impl.rs

index 8a2bbae73f4c42dddc6d798be0834fb5860c481f..56f656f4794624f32f13b6fd5d40e4527246ec56 100644 (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\
 }