aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
authoradamrk <[email protected]>2020-09-02 21:49:21 +0100
committeradamrk <[email protected]>2020-09-02 21:49:21 +0100
commit66658f1168321e1ba3e6aae3f0c038308f0771d7 (patch)
tree11d4a0edd535100b2426f635c412687bcba11f7e /crates/ide/src
parente11cd8fe35fbb4fcaf7859f4cef2dbd94ff7d230 (diff)
Trim mut keyword in fn completion
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/completion/presentation.rs23
1 files changed, 22 insertions, 1 deletions
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 {
225 .flat_map(|(it, param_ty)| { 225 .flat_map(|(it, param_ty)| {
226 if let Some(pat) = it.pat() { 226 if let Some(pat) = it.pat() {
227 let name = pat.to_string(); 227 let name = pat.to_string();
228 let arg = name.trim_start_matches('_'); 228 let arg = name.trim_start_matches("mut ").trim_start_matches('_');
229 return Some(add_arg(arg, param_ty.ty(), ctx)); 229 return Some(add_arg(arg, param_ty.ty(), ctx));
230 } 230 }
231 None 231 None
@@ -962,6 +962,27 @@ fn main() {
962 } 962 }
963 963
964 #[test] 964 #[test]
965 fn trim_mut_keyword_in_func_completion() {
966 check_edit(
967 "take_mutably",
968 r#"
969fn take_mutably(mut x: &i32) {}
970
971fn main() {
972 take_m<|>
973}
974"#,
975 r#"
976fn take_mutably(mut x: &i32) {}
977
978fn main() {
979 take_mutably(${1:x})$0
980}
981"#,
982 );
983 }
984
985 #[test]
965 fn inserts_parens_for_tuple_enums() { 986 fn inserts_parens_for_tuple_enums() {
966 mark::check!(inserts_parens_for_tuple_enums); 987 mark::check!(inserts_parens_for_tuple_enums);
967 check_edit( 988 check_edit(