aboutsummaryrefslogtreecommitdiff
path: root/dw/textblock_linebreaking.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dw/textblock_linebreaking.cc')
-rw-r--r--dw/textblock_linebreaking.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index 6cadca26..02c42339 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -1082,9 +1082,21 @@ void Textblock::fillParagraphs ()
else
firstWordOfLine = 0;
- // If there are no paragraphs yet, findParagraphOfWord will return
- // -1: use 0 then instead.
- int parNo = misc::max (0, findParagraphOfWord (firstWordOfLine));
+ int parNo;
+ if (paragraphs->size() > 0 &&
+ firstWordOfLine > paragraphs->getLastRef()->firstWord)
+ // A special case: the paragraphs list has been partly built, but
+ // not yet the paragraph containing the word in question. In
+ // this case, only the rest of the paragraphs list must be
+ // constructed. (Without this check, findParagraphOfWord would
+ // return -1 in this case, so that all paragraphs would be
+ // rebuilt.)
+ parNo = paragraphs->size ();
+ else
+ // If there are no paragraphs yet, findParagraphOfWord will return
+ // -1: use 0 then instead.
+ parNo = misc::max (0, findParagraphOfWord (firstWordOfLine));
+
paragraphs->setSize (parNo);
int firstWord;