diff options
Diffstat (limited to 'core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt')
-rw-r--r-- | core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt b/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt index e6539135..1eb0c114 100644 --- a/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt +++ b/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt @@ -42,10 +42,9 @@ open class DefaultSampleProcessingService return ContentBlockSampleCode().apply { append(ContentText("//Source not found: $functionName")) } } - val text = processSampleBody(psiElement) - - val lines = text.trimEnd().split("\n".toRegex()).toTypedArray().filterNot(String::isEmpty) - val indent = lines.map { it.takeWhile(Char::isWhitespace).count() }.min() ?: 0 + val text = processSampleBody(psiElement).trim { it == '\n' || it == '\r' }.trimEnd() + val lines = text.split("\n") + val indent = lines.filter(String::isNotBlank).map { it.takeWhile(Char::isWhitespace).count() }.min() ?: 0 val finalText = lines.map { it.drop(indent) }.joinToString("\n") return ContentBlockSampleCode(importsBlock = processImports(psiElement)).apply { append(ContentText(finalText)) } |