question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kotlin output is line wrapping strings

See original GitHub issue

I assume this happens in Java as well but it appears the plugin is introducing new lines, possibly as some form of automatic line-wrapping on spaces.

Simple example:

val alphabet = (65..90)
    .map { it.toChar() }
    .joinToString()

buildConfigField("String", "Example", "\"$alphabet\"")

Results in:

object BuildConfig {
    const val Example: String = "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V,
            W, X, Y, Z"
}

Note the newline breaks the string and the comma after V is at index 99 making me believe that something is forcing 100 character wrapping.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gmazzocommented, Oct 13, 2021

The simple fix is what I show in my 2nd post, if you string replace spaces with the · character, your output will not wrap other than your explicit \n characters. This is a feature of the underlying library used by this plugin, Kotlin Poet.

This should probably be in the readme though if you haven’t already added it. Seems your fix didn’t work which admittedly I haven’t gone back to try yet as my workaround is still working in our project.

Feel free to open a PR for the README.md, you know exactly what we should put on it 😅

1reaction
felixdivocommented, Oct 12, 2021

Oh hey @ToxicBakery, thank’s a lot! I just didn’t get your solution, it now works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java code for wrapping text lines to a max line width
/**Wraps a source String into a series of lines having a maximum specified length. The source is * wrapped at: spaces, horizontal tabs,...
Read more >
Kotlin String and String Templates (With Examples) - Programiz
In this article, you will learn about Kotlin strings, string templates, and few commonly used string properties and functions with the help of...
Read more >
String - Kotlin Programming Language
Creates an Iterable instance that wraps the original char sequence returning its characters when ... Prepends indent to every line of the original...
Read more >
String in Kotlin - Medium
Similar to Python, we can construct a raw string object by wrapping our string in triple double quotes """ . Inside these quotes,...
Read more >
String Templates and Multiline Strings in Kotlin - Knoldus Blogs
Kotlin has an awesome feature called string templates that allows strings to contain template expressions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found