You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to format my multiline expression functions like so:
funfoo() ="bar"funfoo(
bar:BarBarBarBarBarBarBarBarBarBarBarBar,
baz:BarBarBarBarBarBarBarBarBarBarBarBar,
baf:BarBarBarBarBarBarBarBarBarBarBarBar,
bag:BarBarBarBarBarBarBarBarBarBarBarBar,
) =Foo(
bar = bar,
baz = baz
)
Observed Behavior
Instead the second declaration is formatted as:
fun foo(
bar: BarBarBarBarBarBarBarBarBarBarBarBar,
baz: BarBarBarBarBarBarBarBarBarBarBarBar,
baf: BarBarBarBarBarBarBarBarBarBarBarBar,
bag: BarBarBarBarBarBarBarBarBarBarBarBar,
) = Foo(
bar = bar,
baz = baz
)
Steps to Reproduce
My editorconfig has ktlint_function_signature_body_expression_wrapping = always and a max line length to force this parameter list to wrap. The expression wrapping works when the function declaration is a single line (the first function declaration) but not when the function declaration spans lines (the second). Is it possible to achieve what I'm looking for? Thanks!
Your Environment
Version of ktlint used: 1.4.1
Relevant parts of the .editorconfig settings:
"max_line_length" to 120,
"ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than" to 1,
"ktlint_function_signature_body_expression_wrapping" to "always",
Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): Spotless v7 beta 3
Version of Gradle used (if applicable): 8.10
Operating System and version: Mac
The text was updated successfully, but these errors were encountered:
If I recall correctly it is a deliberate exception to not wrap in case the closing parenthesis starts on a newline and has no return type. Reasoning was that the body expression looks a bit "lost" as its indentation is equal to the start position when lines are merged (of course given the widely accepted standard of 4 spaces for indentation):
) =
Foo(
vs
) = Foo(
I do understand that this exception feels weird when .editorconfig property ktlint_function_signature_body_expression_wrapping is set to always. Let me double check this.
Thanks - all of our code is consistently formatted with wrapped expression function bodies and this forces us to be inconsistent in the majority of cases (where we omit the return type).
Expected Behavior
I'd like to format my multiline expression functions like so:
Observed Behavior
Instead the second declaration is formatted as:
Steps to Reproduce
My editorconfig has
ktlint_function_signature_body_expression_wrapping = always
and a max line length to force this parameter list to wrap. The expression wrapping works when the function declaration is a single line (the first function declaration) but not when the function declaration spans lines (the second). Is it possible to achieve what I'm looking for? Thanks!Your Environment
.editorconfig
settings:The text was updated successfully, but these errors were encountered: