Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context keyword causes unexpected formatting of the function paramaters #2854

Open
david-kubecka opened this issue Nov 5, 2024 · 2 comments
Milestone

Comments

@david-kubecka
Copy link

Expected Behavior

All following formattings should be accepted:

    fun test(block: context(Int) () -> Unit = {}) {}

    fun test(
        block: context(Int) () -> Unit = {},
    ) {}

Observed Behavior

ktlint formats both cases as follows:

    fun test(
        block: context(Int)
        () -> Unit = {},
    ) {}

Your Environment

  • ktlint version: 1.3.1
  • editorconfig
[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
max_line_length = 120
trim_trailing_whitespace = true

[*.{kt,kts}]
ktlint_code_style = ktlint_official
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset
@paul-dingemans
Copy link
Collaborator

Thanks for reporting. Minimum requirement should be that the TYPE_REFERENCE context(Int) () -> Unit will not be wrapped. If the type has a default value the equals sign should be on the same line as the type reference. The default value itself is allowed to be wrapped, if it does not fit the line.

@paul-dingemans paul-dingemans added this to the 1.5 milestone Nov 5, 2024
@david-kubecka
Copy link
Author

Agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants