Insert snippet positions after fields names in record patterns

This commit is contained in:
Lukas Wirth 2020-12-21 15:10:27 +01:00
parent 33ecad4407
commit 2cd2947bf8
2 changed files with 6 additions and 6 deletions

View File

@ -156,7 +156,7 @@ fn foo() {
}
"#,
expect![[r#"
bn Bar Bar { ${1:f} }$0
bn Bar Bar { f$1 }$0
"#]],
);
}
@ -171,7 +171,7 @@ struct Foo { bar: String, baz: String }
fn outer(<|>) {}
"#,
expect![[r#"
bn Foo Foo { ${1:bar}, ${2:baz} }: Foo$0
bn Foo Foo { bar$1, baz$2 }: Foo$0
bn Bar Bar($1, $2): Bar$0
"#]],
)
@ -189,7 +189,7 @@ fn outer() {
}
"#,
expect![[r#"
bn Foo Foo { ${1:bar}, ${2:baz} }$0
bn Foo Foo { bar$1, baz$2 }$0
bn Bar Bar($1, $2)$0
"#]],
)
@ -209,7 +209,7 @@ fn outer() {
}
"#,
expect![[r#"
bn Foo Foo { ${1:bar}, ${2:baz} }$0
bn Foo Foo { bar$1, baz$2 }$0
bn Bar Bar($1, $2)$0
"#]],
)
@ -233,7 +233,7 @@ fn outer() {
}
"#,
expect![[r#"
bn Foo Foo { ${1:bar}, .. }$0
bn Foo Foo { bar$1, .. }$0
bn Bar Bar($1, ..)$0
"#]],
)

View File

@ -121,7 +121,7 @@ fn render_record_as_pat(
"{name} {{ {}{} }}",
fields
.enumerate()
.map(|(idx, field)| format!("${{{}:{}}}", idx + 1, field.name(db)))
.map(|(idx, field)| format!("{}${}", field.name(db), idx + 1))
.format(", "),
if fields_omitted { ", .." } else { "" },
name = name