forked from qt-creator/qt-creator
Editor: Fix infinite loop in BaseTextFind
Searching in a blockselection for the regular expressions start of line '^' or line end '$' results in an infinite loop. Only occures when the blockselection didn't contain the searched regular expression. Task-number: QTCREATORBUG-8159 Change-Id: I36412387ecce381300b75d0cd0a452ce5bf1094e Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -338,7 +338,18 @@ QTextCursor BaseTextFind::findOne(const QRegExp &expr, const QTextCursor &from,
|
||||
Q_ARG(QTextCursor, candidate));
|
||||
if (inVerticalFindScope)
|
||||
return candidate;
|
||||
candidate = document()->find(expr, candidate, options);
|
||||
|
||||
QTextCursor newCandidate = document()->find(expr, candidate, options);
|
||||
if (newCandidate == candidate) {
|
||||
// When searching for regular expressions that match "zero length" strings (like ^ or \b)
|
||||
// we need to move away from the match before searching for the next one.
|
||||
candidate.movePosition(options & QTextDocument::FindBackward
|
||||
? QTextCursor::PreviousCharacter
|
||||
: QTextCursor::NextCharacter);
|
||||
candidate = document()->find(expr, candidate, options);
|
||||
} else {
|
||||
candidate = newCandidate;
|
||||
}
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user