[Interest] Bug in QPlainTextEdit::find
Scott Aron Bloom
scott at towel42.com
Wed Sep 16 19:35:15 CEST 2015
Currently, if you set the flags to QTextDocument::FindWholeWords
The system ONLY checks for a boundary of isNumberOrLetter, which is NOT the same as a whole word.
For instance, if you are searching for the whole word "state" and the text is "current_state" is should NOT match, however it does, since _ is not a Number or a Letter.
The offending code is in a static findInBlock, so there is no way to override it..
if ((start != 0 && text.at(start - 1).isLetterOrNumber())
|| (end != text.length() && text.at(end).isLetterOrNumber())) {
My solution was to convert the text into a QRegEx bounded by "\b" on either side
One problem I see, is QChar does not have a "isWordSeparator", that would line allow for an easy replacement of isLetterOrNumber with !isWordSeparator.
My recommendation, would be to add isWordSeparator to QChar, as well as changing the code...
Ideas/thoughts?
Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150916/04290680/attachment.html>
More information about the Interest
mailing list