mirror of
https://github.com/apple/pkl.git
synced 2026-05-27 17:19:15 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user