diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-06-03 14:45:07 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-06-04 07:14:03 +0000 |
commit | a4f79313f065815451610dabdbbb33b8a35f0a86 (patch) | |
tree | fa794e99a27468c258aa0acccd446b3b81625a98 /src/gui/text | |
parent | 7fc67e09f3f0c6c14392702efb01bd861a410fb7 (diff) | |
download | qtbase-a4f79313f065815451610dabdbbb33b8a35f0a86.tar.gz |
Fix: QTextDocument::find backward search crossing paragraphs
If the start position of a backward string search was the at the start
of a paragraph, the code would start searching at an illegal position
(at the eol character) in the preceding paragraph. That caused
that whole paragraph to be skipped, so any matches there
would not be found. Fix by making sure the search starts at legal
position.
Fixes: QTBUG-48035
Change-Id: Id6c0159b6613ec75ec617a0a57096ceef2b4cbd0
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 4f187c6701..c2020f3f86 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1358,6 +1358,8 @@ QTextCursor QTextDocument::find(const QString &subString, int from, FindFlags op blockOffset = 0; } } else { + if (blockOffset == block.length() - 1) + --blockOffset; // make sure to skip end-of-paragraph character while (block.isValid()) { if (findInBlock(block, subString, blockOffset, options, &cursor)) return cursor; |