[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kate] addons/search: use {xxx} syntax for 1112121 replaces
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2016-09-08 20:21:19
Message-ID: E1bi5p1-0003ol-Ow () code ! kde ! org
[Download RAW message or body]

Git commit 1593af0c1152dc0150d8f08d05f6df56bfe14619 by Christoph Cullmann.
Committed on 08/09/2016 at 20:21.
Pushed by cullmann into branch 'master'.

use {xxx} syntax for 1112121 replaces

M  +7    -3    addons/search/replace_matches.cpp

http://commits.kde.org/kate/1593af0c1152dc0150d8f08d05f6df56bfe14619

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("\\"));


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic