diff options
Diffstat (limited to 'crates/ra_ide/src/completion/presentation.rs')
-rw-r--r-- | crates/ra_ide/src/completion/presentation.rs | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index cdfd7bc32..55f75b15a 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs | |||
@@ -174,7 +174,8 @@ impl Completions { | |||
174 | .set_deprecated(is_deprecated(macro_, ctx.db)) | 174 | .set_deprecated(is_deprecated(macro_, ctx.db)) |
175 | .detail(detail); | 175 | .detail(detail); |
176 | 176 | ||
177 | builder = if ctx.use_item_syntax.is_some() { | 177 | builder = if ctx.use_item_syntax.is_some() || ctx.is_macro_call { |
178 | tested_by!(dont_insert_macro_call_parens_unncessary); | ||
178 | builder.insert_text(name) | 179 | builder.insert_text(name) |
179 | } else { | 180 | } else { |
180 | let macro_braces_to_insert = | 181 | let macro_braces_to_insert = |
@@ -960,7 +961,8 @@ mod tests { | |||
960 | } | 961 | } |
961 | 962 | ||
962 | #[test] | 963 | #[test] |
963 | fn dont_insert_macro_call_braces_in_use() { | 964 | fn dont_insert_macro_call_parens_unncessary() { |
965 | covers!(dont_insert_macro_call_parens_unncessary); | ||
964 | assert_debug_snapshot!( | 966 | assert_debug_snapshot!( |
965 | do_reference_completion( | 967 | do_reference_completion( |
966 | r" | 968 | r" |
@@ -986,6 +988,41 @@ mod tests { | |||
986 | }, | 988 | }, |
987 | ] | 989 | ] |
988 | "### | 990 | "### |
989 | ) | 991 | ); |
992 | |||
993 | assert_debug_snapshot!( | ||
994 | do_reference_completion( | ||
995 | r" | ||
996 | //- /main.rs | ||
997 | macro_rules frobnicate { | ||
998 | () => () | ||
999 | } | ||
1000 | fn main() { | ||
1001 | frob<|>!(); | ||
1002 | } | ||
1003 | " | ||
1004 | ), | ||
1005 | @r###" | ||
1006 | [ | ||
1007 | CompletionItem { | ||
1008 | label: "frobnicate!", | ||
1009 | source_range: [56; 60), | ||
1010 | delete: [56; 60), | ||
1011 | insert: "frobnicate", | ||
1012 | kind: Macro, | ||
1013 | detail: "macro_rules! frobnicate", | ||
1014 | }, | ||
1015 | CompletionItem { | ||
1016 | label: "main()", | ||
1017 | source_range: [56; 60), | ||
1018 | delete: [56; 60), | ||
1019 | insert: "main()$0", | ||
1020 | kind: Function, | ||
1021 | lookup: "main", | ||
1022 | detail: "fn main()", | ||
1023 | }, | ||
1024 | ] | ||
1025 | "### | ||
1026 | ); | ||
990 | } | 1027 | } |
991 | } | 1028 | } |