From 66658f1168321e1ba3e6aae3f0c038308f0771d7 Mon Sep 17 00:00:00 2001 From: adamrk Date: Wed, 2 Sep 2020 22:49:21 +0200 Subject: Trim mut keyword in fn completion --- crates/ide/src/completion/presentation.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/completion/presentation.rs b/crates/ide/src/completion/presentation.rs index c7d460465..987cbfa7a 100644 --- a/crates/ide/src/completion/presentation.rs +++ b/crates/ide/src/completion/presentation.rs @@ -225,7 +225,7 @@ impl Completions { .flat_map(|(it, param_ty)| { if let Some(pat) = it.pat() { let name = pat.to_string(); - let arg = name.trim_start_matches('_'); + let arg = name.trim_start_matches("mut ").trim_start_matches('_'); return Some(add_arg(arg, param_ty.ty(), ctx)); } None @@ -961,6 +961,27 @@ fn main() { ); } + #[test] + fn trim_mut_keyword_in_func_completion() { + check_edit( + "take_mutably", + r#" +fn take_mutably(mut x: &i32) {} + +fn main() { + take_m<|> +} +"#, + r#" +fn take_mutably(mut x: &i32) {} + +fn main() { + take_mutably(${1:x})$0 +} +"#, + ); + } + #[test] fn inserts_parens_for_tuple_enums() { mark::check!(inserts_parens_for_tuple_enums); -- cgit v1.2.3