mirror of
https://github.com/apple/pkl.git
synced 2026-04-22 08:18:32 +02:00
This fixes several issues: 1. Leading/trailing line comments surrounding a lambda should make that lambda not "trailing", because the formatting otherwise looks bad and also isn't stable 2. Fix incorrect algorithm for detecting trailing lambda (currently, any number of lambdas makes the alg return `true`)
57 lines
1.1 KiB
Plaintext
Vendored
57 lines
1.1 KiB
Plaintext
Vendored
// multiple lambda arguments means argument list wraps
|
|
res1 =
|
|
foo.toMap(
|
|
(elem) -> elem.toString(),
|
|
(elem) -> elem.toString().split("").map((str) -> str + "hello").toSet(),
|
|
)
|
|
|
|
// new object and trailing lambda means argument list wraps
|
|
res2 =
|
|
foo.doFoo(
|
|
new Listing { 1; 2; 3 },
|
|
(elem) -> elem.toString().split("").map((str) -> str + "hello").toSet(),
|
|
)
|
|
|
|
// single trailing lambda is broken on its own
|
|
res4 =
|
|
foo.foldLeft("heeeeeeelloooooooooooooooooooooooooooooooooooooooooooooo", (elem) ->
|
|
elem.foooooooooooooooooooooooooooooooooooooooooooooooooooo
|
|
)
|
|
|
|
res5 =
|
|
ifNonNull((it) -> someFunctionCall(it as SomeReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongTypeName))
|
|
|
|
res6 =
|
|
ifNonNull((it) ->
|
|
someFunctionCall(it as SomeReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongTypeNameLonger)
|
|
)
|
|
|
|
res7 =
|
|
qux(
|
|
bar,
|
|
(a) -> hello // some comment
|
|
)
|
|
|
|
res8 =
|
|
qux(
|
|
// some comment
|
|
(a) -> bar,
|
|
)
|
|
|
|
res9 =
|
|
qux(
|
|
bar,
|
|
new {
|
|
bar = 1
|
|
} // some comment
|
|
)
|
|
|
|
res10 = (a) -> hello // some comment
|
|
|
|
res11 =
|
|
qux(
|
|
bar,
|
|
(a) -> hello
|
|
// some comment
|
|
)
|