From 30d7ce72b8a0cbf856bd0926d259cb9ffc2e3dc7 Mon Sep 17 00:00:00 2001 From: dece Date: Fri, 28 Jan 2022 12:07:38 +0100 Subject: [PATCH] PageAdapter: fix empty lines issues in pre blocks --- app/src/main/java/dev/lowrespalmtree/comet/PageAdapter.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/dev/lowrespalmtree/comet/PageAdapter.kt b/app/src/main/java/dev/lowrespalmtree/comet/PageAdapter.kt index 434a622..f29649e 100644 --- a/app/src/main/java/dev/lowrespalmtree/comet/PageAdapter.kt +++ b/app/src/main/java/dev/lowrespalmtree/comet/PageAdapter.kt @@ -73,9 +73,11 @@ class PageAdapter(private val listener: ContentAdapterListener) : } is PreTextLine -> { val lastBlock = blocks.last() - if (lastBlock is ContentBlock.Pre && !lastBlock.closed) - lastBlock.content += line.text + "\n" - else + if (lastBlock is ContentBlock.Pre && !lastBlock.closed) { + if (lastBlock.content.isNotEmpty()) + lastBlock.content += "\n" + lastBlock.content += line.text + } else { Log.e(TAG, "setLines: unexpected preformatted line") } }