From d5a84bcb09d1ecadf1876afa86d3c51f15ecf70a Mon Sep 17 00:00:00 2001 From: David Schulz <david.schulz@digia.com> Date: Mon, 26 Nov 2012 15:16:08 +0100 Subject: [PATCH] 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> --- src/plugins/find/basetextfind.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/find/basetextfind.cpp b/src/plugins/find/basetextfind.cpp index e567769d1e2..6f25776c4e2 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); -- GitLab