From 2cd2947bf8cb7abfb06ceb00804447def899d37d Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 21 Dec 2020 15:10:27 +0100 Subject: [PATCH] Insert snippet positions after fields names in record patterns --- crates/completion/src/completions/pattern.rs | 10 +++++----- crates/completion/src/render/pattern.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/completion/src/completions/pattern.rs b/crates/completion/src/completions/pattern.rs index 23a00803c0a..ba9921a4462 100644 --- a/crates/completion/src/completions/pattern.rs +++ b/crates/completion/src/completions/pattern.rs @@ -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 "#]], ) diff --git a/crates/completion/src/render/pattern.rs b/crates/completion/src/render/pattern.rs index 2d16001053b..073d50a114e 100644 --- a/crates/completion/src/render/pattern.rs +++ b/crates/completion/src/render/pattern.rs @@ -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