diff --git a/src/utils/katetemplatehandler.cpp b/src/utils/katetemplatehandler.cpp --- a/src/utils/katetemplatehandler.cpp +++ b/src/utils/katetemplatehandler.cpp @@ -327,7 +327,7 @@ if ( defaultMatch.hasMatch() ) { // the field has a default value, i.e. ${foo=3} f.defaultValue = defaultMatch.captured(1); - f.identifier = contents.split(QLatin1Char('=')).at(0).trimmed(); + f.identifier = contents.leftRef(contents.indexOf(QLatin1Char('='))).trimmed().toString(); } else if ( f.identifier.contains(QLatin1Char('(')) ) { // field is a function call when it contains an opening parenthesis diff --git a/src/view/kateviewhelpers.cpp b/src/view/kateviewhelpers.cpp --- a/src/view/kateviewhelpers.cpp +++ b/src/view/kateviewhelpers.cpp @@ -1188,6 +1188,8 @@ void KateCmdLineEdit::slotReturnPressed(const QString &text) { + static const QRegularExpression focusChangingCommands(QStringLiteral("^(buffer|b|new|vnew|bp|bprev|bn|bnext|bf|bfirst|bl|blast|edit|e)$")); + if (text.isEmpty()) { return; } @@ -1224,8 +1226,8 @@ m_oldText = leadingRangeExpression + cmd; m_msgMode = true; - // the following commands changes the focus themselves, so bar should be hidden before execution. - if (QRegularExpression(QStringLiteral("^(buffer|b|new|vnew|bp|bprev|bn|bnext|bf|bfirst|bl|blast|edit|e)$")).match(cmd.split(QLatin1Char(' ')).at(0)).hasMatch()) { + // if the command changes the focus itself, the bar should be hidden before execution. + if (focusChangingCommands.match(cmd.leftRef(cmd.indexOf(QLatin1Char(' ')))).hasMatch()) { emit hideRequested(); } @@ -1273,8 +1275,7 @@ m_command = nullptr; m_cmdend = 0; - // the following commands change the focus themselves - if (!QRegularExpression(QStringLiteral("^(buffer|b|new|vnew|bp|bprev|bn|bnext|bf|bfirst|bl|blast|edit|e)$")).match(cmd.split(QLatin1Char(' ')).at(0)).hasMatch()) { + if (!focusChangingCommands.match(cmd.leftRef(cmd.indexOf(QLatin1Char(' ')))).hasMatch()) { m_view->setFocus(); } diff --git a/src/vimode/emulatedcommandbar/commandmode.cpp b/src/vimode/emulatedcommandbar/commandmode.cpp --- a/src/vimode/emulatedcommandbar/commandmode.cpp +++ b/src/vimode/emulatedcommandbar/commandmode.cpp @@ -225,7 +225,7 @@ // the following commands change the focus themselves static const QRegularExpression reCmds(QStringLiteral("^(buffer|b|new|vnew|bp|bprev|tabp|tabprev|bn|bnext|tabn|tabnext|bf|bfirst|tabf|tabfirst|bl|blast|tabl|tablast|e|edit|tabe|tabedit|tabnew)$")); - if (!reCmds.match(cmd.split(QLatin1Char(' ')).at(0)).hasMatch()) { + if (!reCmds.match(cmd.leftRef(cmd.indexOf(QLatin1Char(' ')))).hasMatch()) { view()->setFocus(); }