From 9e6e478e0ba624608992eb187c0e621efe70eadb Mon Sep 17 00:00:00 2001 From: Tan Le Date: Wed, 8 Feb 2023 09:22:13 +1100 Subject: [PATCH] Fix highlight of functions in CPP lexer (#1928) 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