Skip to content

Commit 9e6e478

Browse files
authored
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.
1 parent 0806dac commit 9e6e478

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/rouge/lexers/cpp.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ def self.reserved
7171
rule %r/\bnullptr\b/, Name::Builtin
7272
rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
7373
rule %r/(::|<=>)/, Operator
74-
rule %r/[{}]/, Punctuation
74+
rule %r/[{]/, Punctuation
75+
rule %r/}/ do
76+
token Punctuation
77+
pop! if in_state?(:function) # pop :function
78+
end
7579
end
7680

7781
state :classname do

0 commit comments

Comments
 (0)