summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@digia.com>2012-11-26 15:16:08 +0100
committerDavid Schulz <david.schulz@digia.com>2012-11-28 15:31:21 +0100
commitd5a84bcb09d1ecadf1876afa86d3c51f15ecf70a (patch)
treeb4b7f7919fa8c10751580bba66c5552412ce80c0
parent7c5ac43a876bed5d185c94d494cebe274c4586e4 (diff)
downloadqt-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.cpp5
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);