diff options
Diffstat (limited to 'crates/ide_completion/src')
-rw-r--r-- | crates/ide_completion/src/completions/flyimport.rs | 43 | ||||
-rw-r--r-- | crates/ide_completion/src/item.rs | 2 |
2 files changed, 44 insertions, 1 deletions
diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs index 1ad017198..9ace13e41 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#" | ||
1043 | mod m { | ||
1044 | pub fn some_fn() -> i32 { | ||
1045 | 42 | ||
1046 | } | ||
1047 | } | ||
1048 | struct Foo { | ||
1049 | some_field: i32, | ||
1050 | } | ||
1051 | fn 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#" | ||
1063 | mod m { | ||
1064 | pub fn some_fn() -> i32 { | ||
1065 | 42 | ||
1066 | } | ||
1067 | } | ||
1068 | struct Foo { | ||
1069 | some_field: i32, | ||
1070 | } | ||
1071 | fn 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 | } |
diff --git a/crates/ide_completion/src/item.rs b/crates/ide_completion/src/item.rs index cc4ac9ea2..16991b688 100644 --- a/crates/ide_completion/src/item.rs +++ b/crates/ide_completion/src/item.rs | |||
@@ -29,7 +29,7 @@ pub struct CompletionItem { | |||
29 | /// Range of identifier that is being completed. | 29 | /// Range of identifier that is being completed. |
30 | /// | 30 | /// |
31 | /// It should be used primarily for UI, but we also use this to convert | 31 | /// It should be used primarily for UI, but we also use this to convert |
32 | /// genetic TextEdit into LSP's completion edit (see conv.rs). | 32 | /// generic TextEdit into LSP's completion edit (see conv.rs). |
33 | /// | 33 | /// |
34 | /// `source_range` must contain the completion offset. `insert_text` should | 34 | /// `source_range` must contain the completion offset. `insert_text` should |
35 | /// start with what `source_range` points to, or VSCode will filter out the | 35 | /// start with what `source_range` points to, or VSCode will filter out the |