mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Outdentable record builders
This commit is contained in:
parent
b92c50c7be
commit
5edcb31f32
2 changed files with 34 additions and 7 deletions
|
@ -228,7 +228,10 @@ impl<'a> Formattable for Expr<'a> {
|
|||
a.extract_spaces().item.is_multiline()
|
||||
&& matches!(
|
||||
a.value.extract_spaces().item,
|
||||
Expr::Tuple(_) | Expr::List(_) | Expr::Record(_)
|
||||
Expr::Tuple(_)
|
||||
| Expr::List(_)
|
||||
| Expr::Record(_)
|
||||
| Expr::RecordBuilder(_)
|
||||
)
|
||||
&& a.extract_spaces().before == [CommentOrNewline::Newline]
|
||||
})
|
||||
|
@ -560,7 +563,11 @@ pub(crate) fn format_sq_literal(buf: &mut Buf, s: &str) {
|
|||
fn is_outdentable(expr: &Expr) -> bool {
|
||||
matches!(
|
||||
expr.extract_spaces().item,
|
||||
Expr::Tuple(_) | Expr::List(_) | Expr::Record(_) | Expr::Closure(..)
|
||||
Expr::Tuple(_)
|
||||
| Expr::List(_)
|
||||
| Expr::Record(_)
|
||||
| Expr::RecordBuilder(_)
|
||||
| Expr::Closure(..)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1979,20 +1979,40 @@ mod test_fmt {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn multiline_record_builder_func_arg() {
|
||||
fn outdentable_record_builders() {
|
||||
expr_formats_to(
|
||||
indoc!(
|
||||
r#"
|
||||
succeed { a: get "a" |> batch,
|
||||
b: get "b" |> batch,
|
||||
succeed { a: <- get "a" |> batch,
|
||||
b: <- get "b" |> batch,
|
||||
}
|
||||
"#
|
||||
),
|
||||
indoc!(
|
||||
r#"
|
||||
succeed {
|
||||
a: get "a" |> batch,
|
||||
b: get "b" |> batch,
|
||||
a: <- get "a" |> batch,
|
||||
b: <- get "b" |> batch,
|
||||
}
|
||||
"#
|
||||
),
|
||||
);
|
||||
|
||||
expr_formats_to(
|
||||
indoc!(
|
||||
r#"
|
||||
succeed
|
||||
{
|
||||
a: <- get "a" |> batch,
|
||||
b: <- get "b" |> batch,
|
||||
}
|
||||
"#
|
||||
),
|
||||
indoc!(
|
||||
r#"
|
||||
succeed {
|
||||
a: <- get "a" |> batch,
|
||||
b: <- get "b" |> batch,
|
||||
}
|
||||
"#
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue