Respect newlines in if/else and let expressions (#1259)

Change the formatter to prevent multiline if/else and let expressions
from collapsing into a single line.
This commit is contained in:
Daniel Chao
2025-10-28 11:26:31 -07:00
committed by GitHub
parent fbcf83aa76
commit 825fcf5d1d
5 changed files with 86 additions and 5 deletions
@@ -5,3 +5,29 @@ foo =
else
if (someAnotherCondition) 30000
else 4
foo2 = if (bar) 1 else 2
// respect newlines in if/else if they exist.
// if anything of these wrap, everything wraps.
foo3 =
if (bar)
1 else 2
foo4 =
if (bar) 1 else
2
foo5 =
if (bar) 1
else 2
foo6 =
if (bar)
1
else
2
foo7 =
if /* some comment */ (bar) 1
else 2
@@ -15,3 +15,11 @@ qux = let ( // some comment
bar = 5
)
bar
quzzy =
let (baz = 1) baz + 1
// respect newlines in lets
quzzzy =
let (baz = 1)
baz + 1
@@ -7,3 +7,37 @@ foo =
30000
else
4
foo2 = if (bar) 1 else 2
// respect newlines in if/else if they exist.
// if anything of these wrap, everything wraps.
foo3 =
if (bar)
1
else
2
foo4 =
if (bar)
1
else
2
foo5 =
if (bar)
1
else
2
foo6 =
if (bar)
1
else
2
foo7 =
if /* some comment */ (bar)
1
else
2
@@ -25,3 +25,10 @@ qux =
bar = 5
)
bar
quzzy = let (baz = 1) baz + 1
// respect newlines in lets
quzzzy =
let (baz = 1)
baz + 1