Skip to content

Commit 2e91159

Browse files
committed
inline parameters for a function description #6002
Signed-off-by: Benjamin Coenen <[email protected]>
1 parent 7ba578a commit 2e91159

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

crates/ide/src/completion/complete_qualified_path.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,4 +730,26 @@ fn f() {}
730730
expect![[""]],
731731
);
732732
}
733+
734+
#[test]
735+
fn completes_function() {
736+
check(
737+
r#"
738+
fn foo(
739+
a: i32,
740+
b: i32
741+
) {
742+
743+
}
744+
745+
fn main() {
746+
fo<|>
747+
}
748+
"#,
749+
expect![[r#"
750+
fn foo(…) fn foo(a: i32, b: i32)
751+
fn main() fn main()
752+
"#]],
753+
);
754+
}
733755
}

crates/ide/src/display.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ pub(crate) fn function_declaration(node: &ast::Fn) -> String {
4141
format_to!(buf, "{}", type_params);
4242
}
4343
if let Some(param_list) = node.param_list() {
44-
format_to!(buf, "{}", param_list);
44+
let mut params = match param_list.self_param() {
45+
Some(self_param) => vec![self_param.to_string()],
46+
None => vec![],
47+
};
48+
params.extend(param_list.params().map(|param| param.to_string()));
49+
// Useful to inline parameters
50+
format_to!(buf, "({})", params.join(", "));
4551
}
4652
if let Some(ret_type) = node.ret_type() {
4753
if ret_type.ty().is_some() {

0 commit comments

Comments
 (0)