From 7c3614d2b9ac9ed770cf1916db9bd222701290f1 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Thu, 19 Aug 2021 17:50:37 -0400 Subject: [PATCH 1/2] fix(cpp) switch is a keyword --- src/languages/cpp.js | 1 + test/markup/cpp/function-like-keywords.expect.txt | 7 +++++++ test/markup/cpp/function-like-keywords.txt | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 test/markup/cpp/function-like-keywords.expect.txt create mode 100644 test/markup/cpp/function-like-keywords.txt diff --git a/src/languages/cpp.js b/src/languages/cpp.js index e0d10e6a50..443c20efe9 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 (;;) {} From e9bd6d3e8358be9baa0207cbfe810d0ae57b94e6 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Thu, 19 Aug 2021 17:51:30 -0400 Subject: [PATCH 2/2] changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 6d8361a261..ddc54bb318 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ 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][] [Josh Goebel]: https://github.com/joshgoebel