From 12b4cd5a0022603bf14eaba51d82fc602a595d5b Mon Sep 17 00:00:00 2001 From: Tan Le Date: Mon, 6 Feb 2023 12:27:29 +1100 Subject: [PATCH] Fix highlight of functions in CPP lexer This fixes a bug where closing bracket does not pops out of the function state and causes subsequent functions not to be highlighted correctly. This change ensures closing bracket in statements mixin is detecting function state. --- lib/rouge/lexers/cpp.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/cpp.rb b/lib/rouge/lexers/cpp.rb index e9694267a2..3fca7ec788 100644 --- a/lib/rouge/lexers/cpp.rb +++ b/lib/rouge/lexers/cpp.rb @@ -71,7 +71,11 @@ def self.reserved rule %r/\bnullptr\b/, Name::Builtin rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str rule %r/(::|<=>)/, Operator - rule %r/[{}]/, Punctuation + rule %r/[{]/, Punctuation + rule %r/}/ do + token Punctuation + pop! if in_state?(:function) # pop :function + end end state :classname do