Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix syntax colors for numbers with separators and / operator #2881

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/common/navigationstyle.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once

#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
# include <QMetaType>
#endif

enum class NavigationStyle {
Default,
Vi,
Emacs
};

#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
Q_DECLARE_METATYPE(NavigationStyle)
#endif
8 changes: 7 additions & 1 deletion src/gui/commandsyntaxhighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
{
}

Expand Down Expand Up @@ -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 == '\\') {
Expand Down
Loading