From 0bed38576ac0b9bbca6a1a8a691383206ddba116 Mon Sep 17 00:00:00 2001 From: Laury Date: Sat, 18 Sep 2021 21:07:18 +0200 Subject: [PATCH] [reader] Fix bug when changing page --- apps/reader/word_wrap_view.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/reader/word_wrap_view.cpp b/apps/reader/word_wrap_view.cpp index 5cbc012b1..5ed46b1d4 100644 --- a/apps/reader/word_wrap_view.cpp +++ b/apps/reader/word_wrap_view.cpp @@ -69,7 +69,7 @@ void WordWrapTextView::previousPage() { } textEndPosition = textStartPosition; - endOfWord = startOfWord; + endOfWord = startOfWord + 1; } if(startOfWord + 1 == text()) { m_pageOffset = 0; @@ -120,6 +120,10 @@ void WordWrapTextView::drawRect(KDContext * ctx, KDRect rect) const { ++endOfWord; } + //We must change value of startOfWord now to avoid having + //two times the same word if the break below is used + startOfWord = endOfWord; + if(nextTextPosition.y() + textSize.height() > m_frame.height() - k_margin) { // If out of page, quit break; } @@ -131,11 +135,10 @@ void WordWrapTextView::drawRect(KDContext * ctx, KDRect rect) const { } textPosition = nextTextPosition; - startOfWord = endOfWord; endOfWord = UTF8Helper::EndOfWord(startOfWord); } - m_nextPageOffset = endOfWord - text(); + m_nextPageOffset = startOfWord - text(); }; int WordWrapTextView::getPageOffset() const {