fix: record format when module select
- instead of checking the container we need to check the FieldAccess label. closes #601
This commit is contained in:
parent
a5245fdc6b
commit
aeaec6bcd8
|
@ -946,9 +946,7 @@ impl<'comments> Formatter<'comments> {
|
|||
fn call<'a>(&mut self, fun: &'a UntypedExpr, args: &'a [CallArg<UntypedExpr>]) -> Document<'a> {
|
||||
let is_constr = match fun {
|
||||
UntypedExpr::Var { name, .. } => name[0..1].chars().all(|c| c.is_uppercase()),
|
||||
UntypedExpr::FieldAccess { container, .. } => {
|
||||
matches!(&**container, UntypedExpr::Var { name, .. } if name[0..1].chars().all(|c| c.is_uppercase()))
|
||||
}
|
||||
UntypedExpr::FieldAccess { label, .. } => label[0..1].chars().all(|c| c.is_uppercase()),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,23 @@ fn comment_at_end_of_file() {
|
|||
assert_fmt(input, output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_select_record() {
|
||||
let input = indoc! { r#"
|
||||
fn smth() {
|
||||
let a = foo.Foo { bar: 1 }
|
||||
}
|
||||
"#};
|
||||
|
||||
let output = indoc! { r#"
|
||||
fn smth() {
|
||||
let a = foo.Foo { bar: 1 }
|
||||
}
|
||||
"#};
|
||||
|
||||
assert_fmt(input, output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_if() {
|
||||
let src = indoc! {r#"
|
||||
|
|
Loading…
Reference in New Issue