From 2ef3aebaaed6fd2038eaa760278710ea9236ed12 Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Tue, 27 Feb 2024 13:00:46 +0400 Subject: [PATCH 1/3] Support escape in tagged templates --- grammars/rescript.tmLanguage.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index 3c3e6f0da..aba812888 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -160,6 +160,10 @@ } }, "patterns": [ + { + "name": "constant.character.escape", + "match": "\\\\." + }, { "name": "meta.template.expression", "begin": "\\$\\{", @@ -606,4 +610,4 @@ "include": "#defaultIdIsVariable" } ] -} \ No newline at end of file +} From 26569f491a4ffcc993aaa82a803a6868cd1bcb66 Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Tue, 27 Feb 2024 13:11:30 +0400 Subject: [PATCH 2/3] Grammar: use string character escape regex from ts grammar --- grammars/rescript.tmLanguage.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index aba812888..5990a9476 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -119,6 +119,10 @@ } ] }, + "string-character-escape": { + "name": "constant.character.escape", + "match": "\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u{[0-9A-Fa-f]+}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" + }, "string": { "patterns": [ { @@ -137,8 +141,7 @@ }, "patterns": [ { - "name": "constant.character.escape", - "match": "\\\\." + "include": "#string-character-escape" } ] }, @@ -161,8 +164,7 @@ }, "patterns": [ { - "name": "constant.character.escape", - "match": "\\\\." + "include": "#string-character-escape" }, { "name": "meta.template.expression", From d5f1e8da24605a43625b041944043dbf6af43150 Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Tue, 27 Feb 2024 13:18:19 +0400 Subject: [PATCH 3/3] Add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c55b8bc1f..fac0814d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ - Handle completion for DOM/element attributes and attribute values properly when using a generic JSX transform. https://github.com/rescript-lang/rescript-vscode/pull/919 - Highlight tagged template literal functions as functions. https://github.com/rescript-lang/rescript-vscode/pull/920 - Complete for `type t` values when encountering a `type t` in relevant scenarios. https://github.com/rescript-lang/rescript-vscode/pull/924 +- Highlight escaped sequences as a whole and not only the first character. https://github.com/rescript-lang/rescript-vscode/pull/929 +- Start highlighting escaped sequences in template literals. https://github.com/rescript-lang/rescript-vscode/pull/929 ## 1.38.0