aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/fakevim
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2015-12-15 15:15:30 +0100
committerhjk <hjk@theqtcompany.com>2015-12-16 11:41:25 +0000
commit40edcd081348d57619a651cd252128a85692958f (patch)
tree5f10572938ae1bc0f07c1a15521c7f52228c1e28 /src/plugins/fakevim
parent15eadbe555c1d27cca5ba96d3decbb7b5859d998 (diff)
FakeVim: (Un)escape special chars in replacements
Task-number: QTCREATORBUG-15512 Change-Id: Idd625a1ea400e4d2dcae314ddd1a77551c6bb787 Reviewed-by: Lukas Holecek <hluk@email.cz> Reviewed-by: hjk <hjk@theqtcompany.com>
Diffstat (limited to 'src/plugins/fakevim')
-rw-r--r--src/plugins/fakevim/fakevimhandler.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 2da69142473..27b67ba16c4 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -659,6 +659,18 @@ static void bracketSearchForward(QTextCursor *tc, const QString &needleExp, int
}
}
+static char backslashed(char t)
+{
+ switch (t) {
+ case 'e': return 27;
+ case 't': return '\t';
+ case 'r': return '\r';
+ case 'n': return '\n';
+ case 'b': return 8;
+ }
+ return t;
+}
+
static bool substituteText(QString *text, QRegExp &pattern, const QString &replacement,
bool global)
{
@@ -693,7 +705,7 @@ static bool substituteText(QString *text, QRegExp &pattern, const QString &repla
if (c.digitValue() <= pattern.captureCount())
repl += pattern.cap(c.digitValue());
} else {
- repl += c;
+ repl += QLatin1Char(backslashed(c.unicode()));
}
} else {
if (c == QLatin1Char('\\'))