Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.2
-
None
-
Linux: Debian testing
Description
I'm writing an app which uses a QTextEdit to contain text. It also uses hunspell to check spelling, and for that, I use QTextCursor::movePosition() to move from word to word. The code looks like this:
// code placeholder do { while (cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor)) { textEdit->setTextCursor(cursor); QString word = cursor.selectedText(); // etc // Move to the next word >if (! cursor.movePosition(QTextCursor::NextWord, QTextCursor::MoveAnchor)) break; } } while (cursor.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor));
I've found that, if the text contains something like
word word word1
<blank line>
<space: one or more> word2 word2 word2
then movePosition(QTextCursor::NextWord, QTextCursor::MoveAnchor) won't move past word1: it returns false, and we break out of the loop.
Also, if there's another line below it that doesn't have leading spaces, as
<space: one or more> word2 word2 word2
<blank line
word3 word4 word5
then it'll proceed to word5.
Yes, I know it's confusing, which is probably why it's not been reported before (as far as I can tell). Sorry if I've messed up the code view: this is my first bug report for you.