mirror of
https://github.com/apple/pkl.git
synced 2026-03-29 13:21:58 +02:00
Fix formatting of argument lists (#1283)
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`)
This commit is contained in:
@@ -19,3 +19,27 @@ res4 = foo.foldLeft(
|
||||
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
|
||||
)
|
||||
|
||||
@@ -76,8 +76,9 @@ local function render(currentIndent: String) =
|
||||
|
||||
items: List<Item> =
|
||||
allItems
|
||||
.filter((item) ->
|
||||
badItems.containsKey(item) // some line comment
|
||||
|| item.tags.toList().findOrNull((it) -> it.type == "bookmark") != null // some other line comment
|
||||
.filter(
|
||||
(item) ->
|
||||
badItems.containsKey(item) // some line comment
|
||||
|| item.tags.toList().findOrNull((it) -> it.type == "bookmark") != null // some other line comment
|
||||
)
|
||||
.sortBy((item) -> item.name)
|
||||
|
||||
@@ -25,3 +25,32 @@ 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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user