aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authormemoryruins <[email protected]>2021-04-06 23:40:06 +0100
committermemoryruins <[email protected]>2021-04-06 23:40:06 +0100
commitc201cce5277a7280a5933bf7097aecbe250365b9 (patch)
treef3448fc6f4f89b2b0cf497b2022df860acc722f3 /crates
parenta35f7cb6355f00a71a24338eb2d3bfc2920eccb4 (diff)
Do not import on the fly during fields of record literal syntax
Diffstat (limited to 'crates')
-rw-r--r--crates/ide_completion/src/completions/flyimport.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs
index 1ad017198..518114ddd 100644
--- a/crates/ide_completion/src/completions/flyimport.rs
+++ b/crates/ide_completion/src/completions/flyimport.rs
@@ -113,6 +113,7 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext)
113 if ctx.use_item_syntax.is_some() 113 if ctx.use_item_syntax.is_some()
114 || ctx.attribute_under_caret.is_some() 114 || ctx.attribute_under_caret.is_some()
115 || ctx.mod_declaration_under_caret.is_some() 115 || ctx.mod_declaration_under_caret.is_some()
116 || ctx.record_lit_syntax.is_some()
116 { 117 {
117 return None; 118 return None;
118 } 119 }
@@ -1034,4 +1035,46 @@ fn main() {
1034 expect![[]], 1035 expect![[]],
1035 ); 1036 );
1036 } 1037 }
1038
1039 #[test]
1040 fn no_fuzzy_during_fields_of_record_lit_syntax() {
1041 check(
1042 r#"
1043mod m {
1044 pub fn some_fn() -> i32() {
1045 42
1046 }
1047}
1048struct Foo {
1049 some_field: i32,
1050}
1051fn main() {
1052 let _ = Foo { so$0 };
1053}
1054"#,
1055 expect![[]],
1056 );
1057 }
1058
1059 #[test]
1060 fn fuzzy_after_fields_of_record_lit_syntax() {
1061 check(
1062 r#"
1063mod m {
1064 pub fn some_fn() -> i32() {
1065 42
1066 }
1067}
1068struct Foo {
1069 some_field: i32,
1070}
1071fn main() {
1072 let _ = Foo { some_field: so$0 };
1073}
1074"#,
1075 expect![[r#"
1076 fn some_fn() (m::some_fn) fn() -> i32
1077 "#]],
1078 );
1079 }
1037} 1080}