Skip to content

Commit

Permalink
Fix highlight of functions in CPP lexer (#1928)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tancnle committed Feb 7, 2023
1 parent 0806dac commit 9e6e478
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rouge/lexers/cpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9e6e478

Please sign in to comment.