return immediately from render_record_lit
if snippet_cap
is None
this is the record literal version of #13805, which handled the same issue for tuple literals
This commit is contained in:
parent
a97c71f92d
commit
150da92b5c
@ -159,8 +159,9 @@ fn baz() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn enum_variant_no_snippets() {
|
fn enum_variant_no_snippets() {
|
||||||
let conf = CompletionConfig { snippet_cap: SnippetCap::new(false), ..TEST_CONFIG };
|
let conf = CompletionConfig { snippet_cap: SnippetCap::new(false), ..TEST_CONFIG };
|
||||||
|
// tuple variant
|
||||||
check_edit_with_config(
|
check_edit_with_config(
|
||||||
conf,
|
conf.clone(),
|
||||||
"Variant()",
|
"Variant()",
|
||||||
r#"
|
r#"
|
||||||
enum Enum {
|
enum Enum {
|
||||||
@ -178,6 +179,34 @@ enum Enum {
|
|||||||
Variant(usize),
|
Variant(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Enum {
|
||||||
|
fn new(u: usize) -> Self {
|
||||||
|
Self::Variant
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
|
||||||
|
// record variant
|
||||||
|
check_edit_with_config(
|
||||||
|
conf,
|
||||||
|
"Variant{}",
|
||||||
|
r#"
|
||||||
|
enum Enum {
|
||||||
|
Variant{u: usize},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Enum {
|
||||||
|
fn new(u: usize) -> Self {
|
||||||
|
Self::Va$0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
enum Enum {
|
||||||
|
Variant{u: usize},
|
||||||
|
}
|
||||||
|
|
||||||
impl Enum {
|
impl Enum {
|
||||||
fn new(u: usize) -> Self {
|
fn new(u: usize) -> Self {
|
||||||
Self::Variant
|
Self::Variant
|
||||||
|
@ -22,6 +22,9 @@ pub(crate) fn render_record_lit(
|
|||||||
fields: &[hir::Field],
|
fields: &[hir::Field],
|
||||||
path: &str,
|
path: &str,
|
||||||
) -> RenderedLiteral {
|
) -> RenderedLiteral {
|
||||||
|
if snippet_cap.is_none() {
|
||||||
|
return RenderedLiteral { literal: path.to_string(), detail: path.to_string() };
|
||||||
|
}
|
||||||
let completions = fields.iter().enumerate().format_with(", ", |(idx, field), f| {
|
let completions = fields.iter().enumerate().format_with(", ", |(idx, field), f| {
|
||||||
if snippet_cap.is_some() {
|
if snippet_cap.is_some() {
|
||||||
f(&format_args!("{}: ${{{}:()}}", field.name(db), idx + 1))
|
f(&format_args!("{}: ${{{}:()}}", field.name(db), idx + 1))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user