summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2016-09-08 20:21:17 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2016-09-08 20:21:17 (GMT)
commit1593af0c1152dc0150d8f08d05f6df56bfe14619 (patch)
tree53aaff8dbd6f6cef3355edf6195d6978ed796cbe
parentc06dc8d8d63f2c852a4b0adcd012bd2fa2b37e69 (diff)
use {xxx} syntax for 1112121 replaces
-rw-r--r--addons/search/replace_matches.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/addons/search/replace_matches.cpp b/addons/search/replace_matches.cpp
index ba477c5..1c0984f 100644
--- a/addons/search/replace_matches.cpp
+++ b/addons/search/replace_matches.cpp
@@ -154,12 +154,16 @@ void ReplaceMatches::doReplaceNextMatch()
QString replaceText = m_replaceText;
replaceText.replace(QStringLiteral("\\\\"), QStringLiteral("¤Search&Replace¤"));
- // allow captures \0 .. \9999999...
- // replace from large number to small, to not replace e.g. \12 first with capture for \1, see bug 365124
- for (int j = match.lastCapturedIndex(); j >= 0; --j) {
+ // allow captures \0 .. \9
+ for (int j = qMin(9, match.lastCapturedIndex()); j >= 0; --j) {
replaceText.replace(QString(QStringLiteral("\\%1")).arg(j), match.captured(j));
}
+ // allow captures \{0} .. \{9999999}...
+ for (int j = match.lastCapturedIndex(); j >= 0; --j) {
+ replaceText.replace(QString(QStringLiteral("\\{%1}")).arg(j), match.captured(j));
+ }
+
replaceText.replace(QStringLiteral("\\n"), QStringLiteral("\n"));
replaceText.replace(QStringLiteral("\\t"), QStringLiteral("\t"));
replaceText.replace(QStringLiteral("¤Search&Replace¤"), QStringLiteral("\\"));