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:
Daniel Chao authored and GitHub committed 2025-11-03 09:15:58 -08:00
1 parent 4226c21a42
commit d29ae07e14
6 files changed
+82 -33

No files matched your search

@@ -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
)