diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide/src/completion/presentation.rs | 17 | ||||
-rw-r--r-- | crates/ra_ide_db/src/feature_flags.rs | 1 |
2 files changed, 14 insertions, 4 deletions
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index e623c47ec..841d36c8f 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs | |||
@@ -221,16 +221,25 @@ 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 | let snippet = if ctx |
225 | let function_params_snippet = | 225 | .db |
226 | join( | 226 | .feature_flags |
227 | .get("completion.insertion.add-argument-sippets") | ||
228 | { | ||
229 | let to_skip = if has_self_param { 1 } else { 0 }; | ||
230 | let function_params_snippet = join( | ||
227 | function_signature.parameter_names.iter().skip(to_skip).enumerate().map( | 231 | function_signature.parameter_names.iter().skip(to_skip).enumerate().map( |
228 | |(index, param_name)| format!("${{{}:{}}}", index + 1, param_name), | 232 | |(index, param_name)| format!("${{{}:{}}}", index + 1, param_name), |
229 | ), | 233 | ), |
230 | ) | 234 | ) |
231 | .separator(", ") | 235 | .separator(", ") |
232 | .to_string(); | 236 | .to_string(); |
233 | (format!("{}({})$0", name, function_params_snippet), format!("{}(…)", name)) | 237 | format!("{}({})$0", name, function_params_snippet) |
238 | } else { | ||
239 | format!("{}($0)", name) | ||
240 | }; | ||
241 | |||
242 | (snippet, format!("{}(…)", name)) | ||
234 | }; | 243 | }; |
235 | builder = builder.lookup_by(name).label(label).insert_snippet(snippet); | 244 | builder = builder.lookup_by(name).label(label).insert_snippet(snippet); |
236 | } | 245 | } |
diff --git a/crates/ra_ide_db/src/feature_flags.rs b/crates/ra_ide_db/src/feature_flags.rs index 76655f572..d9c9d6cd2 100644 --- a/crates/ra_ide_db/src/feature_flags.rs +++ b/crates/ra_ide_db/src/feature_flags.rs | |||
@@ -54,6 +54,7 @@ impl Default for FeatureFlags { | |||
54 | FeatureFlags::new(&[ | 54 | FeatureFlags::new(&[ |
55 | ("lsp.diagnostics", true), | 55 | ("lsp.diagnostics", true), |
56 | ("completion.insertion.add-call-parenthesis", true), | 56 | ("completion.insertion.add-call-parenthesis", true), |
57 | ("completion.insertion.add-argument-sippets", true), | ||
57 | ("completion.enable-postfix", true), | 58 | ("completion.enable-postfix", true), |
58 | ("notifications.workspace-loaded", true), | 59 | ("notifications.workspace-loaded", true), |
59 | ("notifications.cargo-toml-not-found", true), | 60 | ("notifications.cargo-toml-not-found", true), |