Editor: Fix replace all with regular expression.

Change the accepted length of a search result, if the replacing text
is longer then 0 character. If it would accept also for 0 length
character we would have an endlles loop

Task-Number: QTCREATORBUG-8317
Change-Id: I81a6dccb2a1e16faa6ce8e834ea4b63bae84ecfa
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
David Schulz
2012-11-26 15:16:08 +01:00
parent 7c5ac43a87
commit d5a84bcb09

View File

@@ -256,7 +256,8 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after,
regexp.setPatternSyntax(usesRegExp ? QRegExp::RegExp : QRegExp::FixedString);
regexp.setCaseSensitivity((findFlags & Find::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
QTextCursor found = findOne(regexp, editCursor, Find::textDocumentFlagsForFindFlags(findFlags));
while (!found.isNull() && found.selectionStart() < found.selectionEnd()
while (!found.isNull()
&& (found.selectionStart() < found.selectionEnd() || after.length() > 0)
&& inScope(found.selectionStart(), found.selectionEnd())) {
++count;
editCursor.setPosition(found.selectionStart());