From 96415e2d19df23f9efe293f6ced57a667a6c003b Mon Sep 17 00:00:00 2001 From: Alex Zeier Date: Mon, 20 Oct 2025 05:40:05 -0700 Subject: [PATCH] languages: Separate control flow keywords for JS/TS/TSX (#39801) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #9461, inspired by #39683 `await` and `yield` both seem somewhat debatable on whether they should be considered the be control flow keywords. For now I went with: - `await`: no – The control flow effect of `await` is at a level does not seem relevant for syntax highlighting. - `yield`: yes – `yield` directly affects the output of a generator, and is also included for consistency with Rust (#39683). Happy to change these either direction. SCR-20251008-izus --- Release Notes: - Improved granularity of keyword highlighting for JS/TS/TSX: Themes can now specify `keyword.control` for control flow keywords like `if`, `else`, `return`, etc. --- .../languages/src/javascript/highlights.scm | 35 +++++++++++-------- crates/languages/src/tsx/highlights.scm | 35 +++++++++++-------- .../languages/src/typescript/highlights.scm | 35 +++++++++++-------- 3 files changed, 60 insertions(+), 45 deletions(-) diff --git a/crates/languages/src/javascript/highlights.scm b/crates/languages/src/javascript/highlights.scm index ebeac7efffb8770616fbc94ee4bbf3c25275a198..e5b84ab68df2b32061691f469046569a6597750e 100644 --- a/crates/languages/src/javascript/highlights.scm +++ b/crates/languages/src/javascript/highlights.scm @@ -171,47 +171,52 @@ "as" "async" "await" - "break" - "case" - "catch" "class" "const" - "continue" "debugger" "default" "delete" - "do" - "else" "export" "extends" - "finally" - "for" "from" "function" "get" - "if" "import" "in" "instanceof" "let" "new" "of" - "return" "set" "static" - "switch" "target" - "throw" - "try" "typeof" "using" "var" "void" - "while" "with" - "yield" ] @keyword +[ + "break" + "case" + "catch" + "continue" + "do" + "else" + "finally" + "for" + "if" + "return" + "switch" + "throw" + "try" + "while" + "yield" +] @keyword.control + +(switch_default "default" @keyword.control) + (template_substitution "${" @punctuation.special "}" @punctuation.special) @embedded diff --git a/crates/languages/src/tsx/highlights.scm b/crates/languages/src/tsx/highlights.scm index f7cb987831578f1d3e78decbf89f71c91d3a3b7e..ef12b3d7913e07109e32bb5bf41909511aa2b555 100644 --- a/crates/languages/src/tsx/highlights.scm +++ b/crates/languages/src/tsx/highlights.scm @@ -171,25 +171,16 @@ "as" "async" "await" - "break" - "case" - "catch" "class" "const" - "continue" "debugger" "default" "delete" - "do" - "else" "export" "extends" - "finally" - "for" "from" "function" "get" - "if" "import" "in" "instanceof" @@ -197,23 +188,37 @@ "let" "new" "of" - "return" "satisfies" "set" "static" - "switch" "target" - "throw" - "try" "typeof" "using" "var" "void" - "while" "with" - "yield" ] @keyword +[ + "break" + "case" + "catch" + "continue" + "do" + "else" + "finally" + "for" + "if" + "return" + "switch" + "throw" + "try" + "while" + "yield" +] @keyword.control + +(switch_default "default" @keyword.control) + (template_substitution "${" @punctuation.special "}" @punctuation.special) @embedded diff --git a/crates/languages/src/typescript/highlights.scm b/crates/languages/src/typescript/highlights.scm index 84cbbae77d43c96e62578c444ee913055604e11a..8a85dfea07fe4f50cb271f65ec1bdeeaf2ea150c 100644 --- a/crates/languages/src/typescript/highlights.scm +++ b/crates/languages/src/typescript/highlights.scm @@ -218,27 +218,18 @@ "as" "async" "await" - "break" - "case" - "catch" "class" "const" - "continue" "debugger" "declare" "default" "delete" - "do" - "else" "enum" "export" "extends" - "finally" - "for" "from" "function" "get" - "if" "implements" "import" "in" @@ -257,20 +248,34 @@ "protected" "public" "readonly" - "return" "satisfies" "set" "static" - "switch" "target" - "throw" - "try" "type" "typeof" "using" "var" "void" - "while" "with" - "yield" ] @keyword + +[ + "break" + "case" + "catch" + "continue" + "do" + "else" + "finally" + "for" + "if" + "return" + "switch" + "throw" + "try" + "while" + "yield" +] @keyword.control + +(switch_default "default" @keyword.control)