diff options
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_item.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_item.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 48be812a0..e3bf82304 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -257,7 +257,8 @@ impl Builder { | |||
257 | // If not an import, add parenthesis automatically. | 257 | // If not an import, add parenthesis automatically. |
258 | if ctx.use_item_syntax.is_none() && !ctx.is_call { | 258 | if ctx.use_item_syntax.is_none() && !ctx.is_call { |
259 | tested_by!(inserts_parens_for_function_calls); | 259 | tested_by!(inserts_parens_for_function_calls); |
260 | if function.signature(ctx.db).params().is_empty() { | 260 | let sig = function.signature(ctx.db); |
261 | if sig.params().is_empty() || sig.has_self_param() && sig.params().len() == 1 { | ||
261 | self.insert_text = Some(format!("{}()$0", self.label)); | 262 | self.insert_text = Some(format!("{}()$0", self.label)); |
262 | } else { | 263 | } else { |
263 | self.insert_text = Some(format!("{}($0)", self.label)); | 264 | self.insert_text = Some(format!("{}($0)", self.label)); |
@@ -374,6 +375,18 @@ mod tests { | |||
374 | fn main() { with_<|> } | 375 | fn main() { with_<|> } |
375 | ", | 376 | ", |
376 | ); | 377 | ); |
378 | check_reference_completion( | ||
379 | "inserts_parens_for_function_calls3", | ||
380 | r" | ||
381 | struct S {} | ||
382 | impl S { | ||
383 | fn foo(&self) {} | ||
384 | } | ||
385 | fn bar(s: &S) { | ||
386 | s.f<|> | ||
387 | } | ||
388 | ", | ||
389 | ) | ||
377 | } | 390 | } |
378 | 391 | ||
379 | #[test] | 392 | #[test] |