From e4055c9157770da36d2a2bd854e41db76d7983a7 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 28 May 2024 14:02:05 +0800 Subject: [PATCH] Don't highlight spaces. --- syntax/rhai.JSON-tmLanguage | 4 ++++ syntax/rhai.YAML-tmLanguage | 5 +++++ syntax/rhai.configuration.json | 2 +- syntax/rhai.tmLanguage.json | 4 ++++ test/switch.rhai | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/syntax/rhai.JSON-tmLanguage b/syntax/rhai.JSON-tmLanguage index f7cc387..ad84853 100644 --- a/syntax/rhai.JSON-tmLanguage +++ b/syntax/rhai.JSON-tmLanguage @@ -596,6 +596,10 @@ "name": "keyword.operator.logical.rhai", "match": "(?x)\n !(?!=)| # logical-not right-to-left right\n && | # logical-and left-to-right both\n \\|\\| # logical-or left-to-right both" }, + { + "name": "keyword.operator.containment.rhai", + "match": "(?x)\n \\bin\\b | # in left-to-right both\n \\B!in\\b # not-in left-to-right both" + }, { "name": "keyword.operator.coalesce.rhai", "match": "(?x)\n \\?\\? # null-coalesce left-to-right both" diff --git a/syntax/rhai.YAML-tmLanguage b/syntax/rhai.YAML-tmLanguage index ff21c7f..b9bb721 100644 --- a/syntax/rhai.YAML-tmLanguage +++ b/syntax/rhai.YAML-tmLanguage @@ -340,6 +340,11 @@ repository: !(?!=)| # logical-not right-to-left right && | # logical-and left-to-right both \|\| # logical-or left-to-right both + - name: keyword.operator.containment.rhai + match: >- + (?x) + \bin\b | # in left-to-right both + \B!in\b # not-in left-to-right both - name: keyword.operator.coalesce.rhai match: >- (?x) diff --git a/syntax/rhai.configuration.json b/syntax/rhai.configuration.json index b0bb433..b293fa8 100644 --- a/syntax/rhai.configuration.json +++ b/syntax/rhai.configuration.json @@ -96,7 +96,7 @@ "end": "^\\s*//\\s*#?endregion\\b" } }, - "wordPattern": "[.<>\\0-9a-zA-Z]", + "wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)", "indentationRules": { "increaseIndentPattern": "^((?!\\/\\/).)*(\\{[^}\"'`]*|\\([^)\"'`]*|\\[[^\\]\"'`]*)$", "decreaseIndentPattern": "^((?!.*?\\/\\*).*\\*/)?\\s*[\\}\\]].*$" diff --git a/syntax/rhai.tmLanguage.json b/syntax/rhai.tmLanguage.json index f7cc387..ad84853 100644 --- a/syntax/rhai.tmLanguage.json +++ b/syntax/rhai.tmLanguage.json @@ -596,6 +596,10 @@ "name": "keyword.operator.logical.rhai", "match": "(?x)\n !(?!=)| # logical-not right-to-left right\n && | # logical-and left-to-right both\n \\|\\| # logical-or left-to-right both" }, + { + "name": "keyword.operator.containment.rhai", + "match": "(?x)\n \\bin\\b | # in left-to-right both\n \\B!in\\b # not-in left-to-right both" + }, { "name": "keyword.operator.coalesce.rhai", "match": "(?x)\n \\?\\? # null-coalesce left-to-right both" diff --git a/test/switch.rhai b/test/switch.rhai index c82fe79..f25f58b 100644 --- a/test/switch.rhai +++ b/test/switch.rhai @@ -5,7 +5,7 @@ let arr = [42, 123.456, "hello", true, "hey", 'x', 999, 1, 2, 3, 4]; for item in arr { switch item { // Match single character - 'f' => |a, b| a > b, + 'f' => |a, b| a !in b, // Match single integer 42 => print("The Answer!"), // Match a selection