From c201cce5277a7280a5933bf7097aecbe250365b9 Mon Sep 17 00:00:00 2001 From: memoryruins Date: Tue, 6 Apr 2021 18:40:06 -0400 Subject: Do not import on the fly during fields of record literal syntax --- crates/ide_completion/src/completions/flyimport.rs | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) 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) if ctx.use_item_syntax.is_some() || ctx.attribute_under_caret.is_some() || ctx.mod_declaration_under_caret.is_some() + || ctx.record_lit_syntax.is_some() { return None; } @@ -1034,4 +1035,46 @@ fn main() { expect![[]], ); } + + #[test] + fn no_fuzzy_during_fields_of_record_lit_syntax() { + check( + r#" +mod m { + pub fn some_fn() -> i32() { + 42 + } +} +struct Foo { + some_field: i32, +} +fn main() { + let _ = Foo { so$0 }; +} +"#, + expect![[]], + ); + } + + #[test] + fn fuzzy_after_fields_of_record_lit_syntax() { + check( + r#" +mod m { + pub fn some_fn() -> i32() { + 42 + } +} +struct Foo { + some_field: i32, +} +fn main() { + let _ = Foo { some_field: so$0 }; +} +"#, + expect![[r#" + fn some_fn() (m::some_fn) fn() -> i32 + "#]], + ); + } } -- cgit v1.2.3 From e1e6e3b925bf7e0f6ca6cbc0d63d59572752653d Mon Sep 17 00:00:00 2001 From: memoryruins Date: Tue, 6 Apr 2021 19:38:59 -0400 Subject: Fix typo --- crates/ide_completion/src/completions/flyimport.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs index 518114ddd..9ace13e41 100644 --- a/crates/ide_completion/src/completions/flyimport.rs +++ b/crates/ide_completion/src/completions/flyimport.rs @@ -1041,7 +1041,7 @@ fn main() { check( r#" mod m { - pub fn some_fn() -> i32() { + pub fn some_fn() -> i32 { 42 } } @@ -1061,7 +1061,7 @@ fn main() { check( r#" mod m { - pub fn some_fn() -> i32() { + pub fn some_fn() -> i32 { 42 } } -- cgit v1.2.3