Kotlin / Kotlin/ktfmt

Does not break at higher syntactic level

Open
#257 1 comment 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Kotlin
Stars
1.3k
Forks
116
Avg merge
4d 10h
Merged PRs (30d)
15

Description

When type parameters on a function call cause the line width to be exceeded, ktfmt breaks on the type parameters:
```kotlin
VeryLongNamedServiceMocker.whenever(VeryLongNamedServiceMocker.Method.FunctionName).thenRespond<
LongType> {
// do a thing
}
```

Instead, I would expect the line to be broken at the higher syntactic level, such as
```
VeryLongNamedServiceMocker.whenever(VeryLongNamedServiceMocker.Method.FunctionName)
.thenRespond {
// do a thing
}
```
or
```
VeryLongNamedServiceMocker
.whenever(VeryLongNamedServiceMocker.Method.FunctionName)
.thenRespond {
// do a thing
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported Kotlin formatting case with the chained call and generic type parameter shown in the issue. Compare the current output with the two expected higher-level breaks; done means the formatter chooses a higher syntactic break instead of splitting the type parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.