From e4226f5724c5a8fad85a95ead2123bde49c070a4 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sun, 29 Aug 2021 15:25:04 -0400 Subject: [PATCH] fix(cpp) switch is a keyword (#3312) --- CHANGES.md | 5 +++-- src/languages/cpp.js | 1 + test/markup/cpp/function-like-keywords.expect.txt | 7 +++++++ test/markup/cpp/function-like-keywords.txt | 8 ++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 test/markup/cpp/function-like-keywords.expect.txt create mode 100644 test/markup/cpp/function-like-keywords.txt diff --git a/CHANGES.md b/CHANGES.md index c38f3158e7..d0ad3f8cab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,8 @@ ## Version 11.3.0 (most likely) -enh(css/less/stylus/scss) improve consistency of function dispatch (#3301) [Josh Goebel][] -enh(css/less/stylus/scss) detect block comments more fully (#3301) [Josh Goebel][] +- enh(css/less/stylus/scss) improve consistency of function dispatch (#3301) [Josh Goebel][] +- enh(css/less/stylus/scss) detect block comments more fully (#3301) [Josh Goebel][] +- fix(cpp) switch is a keyword (#3312) [Josh Goebel][] - fix(cpp) fix `xor_eq` keyword highlighting. [Denis Kovalchuk][] - enh(css/less/stylus/scss) add support for CSS Grid properties [monochromer][] diff --git a/src/languages/cpp.js b/src/languages/cpp.js index ecf89cdd64..2c1976e588 100644 --- a/src/languages/cpp.js +++ b/src/languages/cpp.js @@ -411,6 +411,7 @@ export default function(hljs) { /(?!decltype)/, /(?!if)/, /(?!for)/, + /(?!switch)/, /(?!while)/, hljs.IDENT_RE, regex.lookahead(/(<[^<>]+>|)\s*\(/)) diff --git a/test/markup/cpp/function-like-keywords.expect.txt b/test/markup/cpp/function-like-keywords.expect.txt new file mode 100644 index 0000000000..f58427e223 --- /dev/null +++ b/test/markup/cpp/function-like-keywords.expect.txt @@ -0,0 +1,7 @@ +if (ch) {} + +switch (ch) {} + +while (ch) {} + +for (;;) {} diff --git a/test/markup/cpp/function-like-keywords.txt b/test/markup/cpp/function-like-keywords.txt new file mode 100644 index 0000000000..514676c0a0 --- /dev/null +++ b/test/markup/cpp/function-like-keywords.txt @@ -0,0 +1,8 @@ + +if (ch) {} + +switch (ch) {} + +while (ch) {} + +for (;;) {}