Skip to content

Commit dff1339

Browse files
committed
fix: Fix param inlayHints on empty expr and comma
Example --- ```rust pub fn test(a: i32, b: i32, c: i32) {} fn main() { test(, 2,); test(, , 3); } ``` **Before this PR** ```rust test(, 2,); //^ a test(, , 3); //^ a ``` **After this PR** ```rust test(, 2,); //^ b test(, , 3); //^ c ```
1 parent f53d93e commit dff1339

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

crates/ide/src/inlay_hints/param_name.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ pub(super) fn hints(
3737
let hints = callable
3838
.params()
3939
.into_iter()
40-
.zip(arg_list.args())
40+
.zip(arg_list.args_maybe_empty())
4141
.filter_map(|(p, arg)| {
42+
let arg = arg?;
4243
// Only annotate hints for expressions that exist in the original file
4344
let range = sema.original_range_opt(arg.syntax())?;
4445
if range.file_id != file_id {
@@ -561,6 +562,19 @@ fn main() {
561562
)
562563
}
563564

565+
#[test]
566+
fn param_name_hints_show_after_empty_arg() {
567+
check_params(
568+
r#"pub fn test(a: i32, b: i32, c: i32) {}
569+
fn main() {
570+
test(, 2,);
571+
//^ b
572+
test(, , 3);
573+
//^ c
574+
}"#,
575+
)
576+
}
577+
564578
#[test]
565579
fn function_call_parameter_hint() {
566580
check_params(

0 commit comments

Comments
 (0)