Chris Lee
07/21/2023, 2:04 AMval sourceProperty =
environment.getProperty(
pair.first,
)
(removing the trailing ,
doesn’t change this.
ktlint 0.50.0, with this in `.editorconfig`:
[*.{kts,kt}]
indent_size = 4
max_line_length = 200
ktlint_code_style = ktlint_official
ktlint_standard_max-line-length = disabled
ktlint_standard_property-naming = disabled
ktlint_experimental=enabled
ij_kotlin_packages_to_use_import_on_demand = java.util.*
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
In IntelliJ can partially address this by turning off `Keep when reformatting -> Line breaks`; result:
val sourceProperty = environment.getProperty(
pair.first,
)
(goal would be for this all to be on one line as it shouldn’t wrap)
Possible to achieve this with ktlint? If not, happy to help with a PR for this.Paul Dingemans
07/22/2023, 2:49 PMwrapping
rule.
What can be done, is that you create a new rule that rewrites a construction like a function call as in your example. The difference is that such a rule completely rewrites a function call and inserts newlines when the function call does not fit a line or removes newlines when the call can fit a single line. You can take a look at the function-signature
and the new yet unreleased class-signature
to get an idea how this can be done. In your example above, this would mean, that you will only rewrite following:
getProperty(
pair.first,
)
Reason for this, is that the .
expression will be rewritten by yet another rule (in progress).
It can be challenging (but very satisfying) to write a rule like this. I strongly encourage a TDD approach and test only 1 thing in a single test. Please submit a PR in an early stage so that I can help/review you before you spend too much time on it.Chris Lee
07/22/2023, 2:58 PMPaul Dingemans
07/22/2023, 3:01 PMChris Lee
07/22/2023, 3:02 PM