aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/presentation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/completion/presentation.rs')
-rw-r--r--crates/ra_ide/src/completion/presentation.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs
index dc391c46b..946bbef7c 100644
--- a/crates/ra_ide/src/completion/presentation.rs
+++ b/crates/ra_ide/src/completion/presentation.rs
@@ -174,6 +174,7 @@ impl Completions {
174 builder 174 builder
175 .insert_snippet(cap, format!("{}!{}$0{}", name, bra, ket)) 175 .insert_snippet(cap, format!("{}!{}$0{}", name, bra, ket))
176 .label(format!("{}!{}…{}", name, bra, ket)) 176 .label(format!("{}!{}…{}", name, bra, ket))
177 .lookup_by(format!("{}!", name))
177 } 178 }
178 None if needs_bang => builder.insert_text(format!("{}!", name)), 179 None if needs_bang => builder.insert_text(format!("{}!", name)),
179 _ => { 180 _ => {
@@ -1079,4 +1080,57 @@ fn go(world: &WorldSnapshot) { go(w<|>) }
1079 "#]], 1080 "#]],
1080 ); 1081 );
1081 } 1082 }
1083
1084 #[test]
1085 fn guesses_macro_braces() {
1086 check_edit(
1087 "vec!",
1088 r#"
1089/// Creates a [`Vec`] containing the arguments.
1090///
1091/// ```
1092/// let v = vec![1, 2, 3];
1093/// assert_eq!(v[0], 1);
1094/// assert_eq!(v[1], 2);
1095/// assert_eq!(v[2], 3);
1096/// ```
1097macro_rules! vec { () => {} }
1098
1099fn fn main() { v<|> }
1100"#,
1101 r#"
1102/// Creates a [`Vec`] containing the arguments.
1103///
1104/// ```
1105/// let v = vec![1, 2, 3];
1106/// assert_eq!(v[0], 1);
1107/// assert_eq!(v[1], 2);
1108/// assert_eq!(v[2], 3);
1109/// ```
1110macro_rules! vec { () => {} }
1111
1112fn fn main() { vec![$0] }
1113"#,
1114 );
1115
1116 check_edit(
1117 "foo!",
1118 r#"
1119/// Foo
1120///
1121/// Don't call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`,
1122/// call as `let _=foo! { hello world };`
1123macro_rules! foo { () => {} }
1124fn main() { <|> }
1125"#,
1126 r#"
1127/// Foo
1128///
1129/// Don't call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`,
1130/// call as `let _=foo! { hello world };`
1131macro_rules! foo { () => {} }
1132fn main() { foo! {$0} }
1133"#,
1134 )
1135 }
1082} 1136}