diff --git a/src/common/navigationstyle.h b/src/common/navigationstyle.h index 13f0196a0..cfbae0e9a 100644 --- a/src/common/navigationstyle.h +++ b/src/common/navigationstyle.h @@ -1,8 +1,17 @@ // SPDX-License-Identifier: GPL-3.0-or-later #pragma once +#include +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +# include +#endif + enum class NavigationStyle { Default, Vi, Emacs }; + +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +Q_DECLARE_METATYPE(NavigationStyle) +#endif diff --git a/src/gui/commandsyntaxhighlighter.cpp b/src/gui/commandsyntaxhighlighter.cpp index ad04a8d34..4d08124bf 100644 --- a/src/gui/commandsyntaxhighlighter.cpp +++ b/src/gui/commandsyntaxhighlighter.cpp @@ -76,7 +76,7 @@ class CommandSyntaxHighlighter final : public QSyntaxHighlighter , m_reFunctions(createRegExp(scriptableFunctions())) , m_reKeywords(createRegExp(scriptableKeywords())) , m_reLabels(commandLabelRegExp()) - , m_reConstants("\\b0x[0-9A-Fa-f]+|(?:\\b|%)\\d+|\\btrue\\b|\\bfalse\\b") + , m_reConstants(R"(\b0x[0-9A-Fa-f](?:_?[0-9A-Fa-f])*|(?:\b|%)\d(?:_?\d)*|\btrue\b|\bfalse\b)") { } @@ -198,8 +198,14 @@ class CommandSyntaxHighlighter final : public QSyntaxHighlighter if (i == -1) i = text.size(); + --i; format(a, i); + setCurrentBlockState(Code); + } else if (c == '\n' || i + 1 == text.size()) { + // The '/' was not regex start, since there is no ending + // '/' on the same line. + i = a; setCurrentBlockState(Code); } } else if (c == '\\') {