Skip to content

Commit 042c248

Browse files
Merge #8526
8526: fix: Do not show flyimports in trait or impl declarations r=SomeoneToIgnore a=SomeoneToIgnore Part of #8518 Removes autoimport suggestions for the case: > inside trait definitions / impls (trait Trait {$0} / impl Foo {$0}), nothing except the fn, type and const keywords (and the full item completions for trait impls) should appear (currently many types and autoimport suggestions) Co-authored-by: Kirill Bulatov <[email protected]>
2 parents e131bfc + 1c75d64 commit 042c248

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

crates/ide_completion/src/completions/flyimport.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext)
114114
|| ctx.attribute_under_caret.is_some()
115115
|| ctx.mod_declaration_under_caret.is_some()
116116
|| ctx.record_lit_syntax.is_some()
117+
|| ctx.has_trait_parent
118+
|| ctx.has_impl_parent
117119
{
118120
return None;
119121
}
@@ -1077,4 +1079,52 @@ fn main() {
10771079
"#]],
10781080
);
10791081
}
1082+
1083+
#[test]
1084+
fn no_flyimports_in_traits_and_impl_declarations() {
1085+
check(
1086+
r#"
1087+
mod m {
1088+
pub fn some_fn() -> i32 {
1089+
42
1090+
}
1091+
}
1092+
trait Foo {
1093+
som$0
1094+
}
1095+
"#,
1096+
expect![[r#""#]],
1097+
);
1098+
1099+
check(
1100+
r#"
1101+
mod m {
1102+
pub fn some_fn() -> i32 {
1103+
42
1104+
}
1105+
}
1106+
struct Foo;
1107+
impl Foo {
1108+
som$0
1109+
}
1110+
"#,
1111+
expect![[r#""#]],
1112+
);
1113+
1114+
check(
1115+
r#"
1116+
mod m {
1117+
pub fn some_fn() -> i32 {
1118+
42
1119+
}
1120+
}
1121+
struct Foo;
1122+
trait Bar {}
1123+
impl Bar for Foo {
1124+
som$0
1125+
}
1126+
"#,
1127+
expect![[r#""#]],
1128+
);
1129+
}
10801130
}

0 commit comments

Comments
 (0)