Skip to content

Commit

Permalink
fix indent bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jillesvangurp committed Feb 17, 2024
1 parent c5b8a2a commit 867fa49
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ Simply add a simple extension function like this:.
context(Kotlin4Example)!
fun ExampleOutput<*>.printStdOut() {
+"""
This prints:
This prints:
""".trimIndent()

mdCodeBlock(stdOut, type = "text", wrap = true)
}
}
```

And then you can use it `example { 1+1}.printStdOut()`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ fun String.reIndent(indent: Int=2): String {
return this.lines().firstOrNull {
val whiteSpace = spaceFinder.find(it)?.value
whiteSpace?.let {
whiteSpace.length > indent
whiteSpace.length >= indent
} == true
}?.let {
val whiteSpace = spaceFinder.find(it)!!.groups[1]!!.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,16 @@ class KotlinForExampleTest {
}
""".trimIndent()
}

@Test
fun `should not reindent already indented`() {
val json="""
{
"foo": {
"bar": "foo"
}
}
""".trimIndent()
json.reIndent() shouldBe json
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ val readmeMarkdown by k4ERepo.md {
context(Kotlin4Example)!
fun ExampleOutput<*>.printStdOut() {
+""${'"'}
This prints:
This prints:
""${'"'}.trimIndent()
mdCodeBlock(stdOut, type = "text", wrap = true)
}
}
""".trimIndent(), "kotlin")

+"""
Expand Down

0 comments on commit 867fa49

Please sign in to comment.