Kotlin / Kotlin/ktfmt

Feature request: Automatic breaking of very long strings

Open
#219 2 comments 2 reactions 0 assignees View on GitHub
enhancement formatting-discussions
Dominant language
Kotlin
Stars
1.3k
Forks
116
Avg merge
4d 10h
Merged PRs (30d)
15

Description

When encountering strings that are over (or very near) the character limit, ktfmt makes no attempt to break the strings. Should it?

e.g. This code is not modified in any way, despite the fact that the last line exceeds 100 characters:
```kotlin
val name
get() =
"A very very very long string that probably should be wrapped; should this be done automatically?"
```

one possible fix:
```kotlin
val name
get() =
"A very very very long string that probably should be wrapped; should this be done " +
"automatically?"
```

Contributor guide

Open the contributing guide

Research direction

The issue names no repository files, tests, or entry points. Start by locating ktfmt's handling of Kotlin string literals and its line-breaking tests, then clarify when and how strings should be split. Done should include automatic breaking for strings over or near the character limit, with output matching the proposed concatenation style and respecting the limit.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.