From a28180b98a1e84f2d1e5d068e4ed4777c661054f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Mon, 28 Apr 2025 13:04:04 +0100 Subject: [PATCH 1/3] Require whitespace before `as` in `to`/`downto` labels The `RE_TO_DOWNTO_AS_LABELS` rule previously used `\s*` between `(to|downto)` and `(as)`, allowing zero spaces and accidentally matching identifiers like "toast". Change the pattern to `\s+` so that an actual space is required, preventing spurious `as` highlighting inside identifiers. --- grammars/rescript.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index c01154554..ef5760f48 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -21,7 +21,7 @@ } }, { - "match": "(to|downto)\\s*(as)", + "match": "(to|downto)\\s+(as)", "captures": { "1": { "name": "variable" From 610bc2b21ff95ef897c366739b6a01ca29778374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Mon, 28 Apr 2025 13:07:27 +0100 Subject: [PATCH 2/3] Prefix `RE_TO_DOWNTO_AS_LABELS` patterns with `~` to ensure they only apply to labelled arguments --- grammars/rescript.tmLanguage.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index ef5760f48..7a5bade0f 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -10,7 +10,7 @@ "RE_TO_DOWNTO_AS_LABELS": { "patterns": [ { - "match": "(to|downto)\\s*(=)", + "match": "~(to|downto)\\s*(=)", "captures": { "1": { "name": "variable" @@ -21,7 +21,7 @@ } }, { - "match": "(to|downto)\\s+(as)", + "match": "~(to|downto)\\s+(as)", "captures": { "1": { "name": "variable" From a7b302ad0fe35d87f2a85e09dc106c91d19e9b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Mon, 28 Apr 2025 14:09:37 +0100 Subject: [PATCH 3/3] Add CHANGELOG entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00097105b..3df13a94f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ #### :bug: Bug fix +- Fix: incorrect highlighting of `as` inside labelled arguments like `toast` https://github.com/rescript-lang/rescript-vscode/pull/1085 + - Fix: bug where incremental analysis does not work when the project folder contains a dot. https://github.com/rescript-lang/rescript-vscode/pull/1080 - Fix: bug where incremental compilation crashes when rewatch is being run in a specific package vs the root of the monorepo. https://github.com/rescript-lang/rescript-vscode/pull/1082