aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/presentation.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-06 17:09:58 +0000
committerGitHub <[email protected]>2020-03-06 17:09:58 +0000
commit8e8c5a73ff3b26a7c919fee6caa3212dca9c6ba5 (patch)
tree22a0cb43006931d9acfb77940b2cda2d16f702d6 /crates/ra_ide/src/completion/presentation.rs
parentce7496ec2227746cfcd2147fadf58fa71f65e35b (diff)
parent3ff170d65872d9965c4bd88184701d957f23570e (diff)
Merge #3498
3498: Trigger parameter info automatically r=matklad a=matklad See https://github.com/Microsoft/vscode/issues/64023 bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/completion/presentation.rs')
-rw-r--r--crates/ra_ide/src/completion/presentation.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs
index dac232a85..d6196a5ce 100644
--- a/crates/ra_ide/src/completion/presentation.rs
+++ b/crates/ra_ide/src/completion/presentation.rs
@@ -103,7 +103,7 @@ impl Completions {
103 } 103 }
104 }; 104 };
105 105
106 // If not an import, add parenthesis automatically. 106 // Add `<>` for generic types
107 if ctx.is_path_type 107 if ctx.is_path_type
108 && !ctx.has_type_args 108 && !ctx.has_type_args
109 && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis") 109 && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis")
@@ -211,7 +211,7 @@ impl Completions {
211 .set_deprecated(is_deprecated(func, ctx.db)) 211 .set_deprecated(is_deprecated(func, ctx.db))
212 .detail(function_signature.to_string()); 212 .detail(function_signature.to_string());
213 213
214 // Add `<>` for generic types 214 // If not an import, add parenthesis automatically.
215 if ctx.use_item_syntax.is_none() 215 if ctx.use_item_syntax.is_none()
216 && !ctx.is_call 216 && !ctx.is_call
217 && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis") 217 && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis")
@@ -221,16 +221,26 @@ impl Completions {
221 let (snippet, label) = if params.is_empty() || has_self_param && params.len() == 1 { 221 let (snippet, label) = if params.is_empty() || has_self_param && params.len() == 1 {
222 (format!("{}()$0", name), format!("{}()", name)) 222 (format!("{}()$0", name), format!("{}()", name))
223 } else { 223 } else {
224 let to_skip = if has_self_param { 1 } else { 0 }; 224 builder = builder.trigger_call_info();
225 let function_params_snippet = 225 let snippet = if ctx
226 join( 226 .db
227 .feature_flags
228 .get("completion.insertion.add-argument-sippets")
229 {
230 let to_skip = if has_self_param { 1 } else { 0 };
231 let function_params_snippet = join(
227 function_signature.parameter_names.iter().skip(to_skip).enumerate().map( 232 function_signature.parameter_names.iter().skip(to_skip).enumerate().map(
228 |(index, param_name)| format!("${{{}:{}}}", index + 1, param_name), 233 |(index, param_name)| format!("${{{}:{}}}", index + 1, param_name),
229 ), 234 ),
230 ) 235 )
231 .separator(", ") 236 .separator(", ")
232 .to_string(); 237 .to_string();
233 (format!("{}({})$0", name, function_params_snippet), format!("{}(…)", name)) 238 format!("{}({})$0", name, function_params_snippet)
239 } else {
240 format!("{}($0)", name)
241 };
242
243 (snippet, format!("{}(…)", name))
234 }; 244 };
235 builder = builder.lookup_by(name).label(label).insert_snippet(snippet); 245 builder = builder.lookup_by(name).label(label).insert_snippet(snippet);
236 } 246 }