diff options
author | David Schulz <david.schulz@digia.com> | 2012-11-26 15:16:08 +0100 |
---|---|---|
committer | David Schulz <david.schulz@digia.com> | 2012-11-28 15:31:21 +0100 |
commit | d5a84bcb09d1ecadf1876afa86d3c51f15ecf70a (patch) | |
tree | b4b7f7919fa8c10751580bba66c5552412ce80c0 | |
parent | 7c5ac43a876bed5d185c94d494cebe274c4586e4 (diff) | |
download | qt-creator-d5a84bcb09d1ecadf1876afa86d3c51f15ecf70a.tar.gz |
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>
-rw-r--r-- | src/plugins/find/basetextfind.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/find/basetextfind.cpp b/src/plugins/find/basetextfind.cpp index e567769d1e..6f25776c4e 100644 --- a/src/plugins/find/basetextfind.cpp +++ b/src/plugins/find/basetextfind.cpp @@ -256,8 +256,9 @@ 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() - && inScope(found.selectionStart(), found.selectionEnd())) { + while (!found.isNull() + && (found.selectionStart() < found.selectionEnd() || after.length() > 0) + && inScope(found.selectionStart(), found.selectionEnd())) { ++count; editCursor.setPosition(found.selectionStart()); editCursor.setPosition(found.selectionEnd(), QTextCursor::KeepAnchor); |