Skip to content

Commit 66658f1

Browse files
committed
Trim mut keyword in fn completion
1 parent e11cd8f commit 66658f1

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

crates/ide/src/completion/presentation.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl Completions {
225225
.flat_map(|(it, param_ty)| {
226226
if let Some(pat) = it.pat() {
227227
let name = pat.to_string();
228-
let arg = name.trim_start_matches('_');
228+
let arg = name.trim_start_matches("mut ").trim_start_matches('_');
229229
return Some(add_arg(arg, param_ty.ty(), ctx));
230230
}
231231
None
@@ -961,6 +961,27 @@ fn main() {
961961
);
962962
}
963963

964+
#[test]
965+
fn trim_mut_keyword_in_func_completion() {
966+
check_edit(
967+
"take_mutably",
968+
r#"
969+
fn take_mutably(mut x: &i32) {}
970+
971+
fn main() {
972+
take_m<|>
973+
}
974+
"#,
975+
r#"
976+
fn take_mutably(mut x: &i32) {}
977+
978+
fn main() {
979+
take_mutably(${1:x})$0
980+
}
981+
"#,
982+
);
983+
}
984+
964985
#[test]
965986
fn inserts_parens_for_tuple_enums() {
966987
mark::check!(inserts_parens_for_tuple_enums);

0 commit comments

Comments
 (0)