Skip to content

Commit 86bff5a

Browse files
DZakhaspeddro
authored andcommitted
Improve syntax highligting for escaped characters (rescript-lang#929)
* Support escape in tagged templates * Grammar: use string character escape regex from ts grammar * Add changelog
1 parent dd28967 commit 86bff5a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
- 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
2323
- Highlight tagged template literal functions as functions. https://github.com/rescript-lang/rescript-vscode/pull/920
2424
- Complete for `type t` values when encountering a `type t` in relevant scenarios. https://github.com/rescript-lang/rescript-vscode/pull/924
25+
- Highlight escaped sequences as a whole and not only the first character. https://github.com/rescript-lang/rescript-vscode/pull/929
26+
- Start highlighting escaped sequences in template literals. https://github.com/rescript-lang/rescript-vscode/pull/929
2527

2628
## 1.38.0
2729

Diff for: grammars/rescript.tmLanguage.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@
119119
}
120120
]
121121
},
122+
"string-character-escape": {
123+
"name": "constant.character.escape",
124+
"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]?|.|$)"
125+
},
122126
"string": {
123127
"patterns": [
124128
{
@@ -137,8 +141,7 @@
137141
},
138142
"patterns": [
139143
{
140-
"name": "constant.character.escape",
141-
"match": "\\\\."
144+
"include": "#string-character-escape"
142145
}
143146
]
144147
},
@@ -160,6 +163,9 @@
160163
}
161164
},
162165
"patterns": [
166+
{
167+
"include": "#string-character-escape"
168+
},
163169
{
164170
"name": "meta.template.expression",
165171
"begin": "\\$\\{",
@@ -606,4 +612,4 @@
606612
"include": "#defaultIdIsVariable"
607613
}
608614
]
609-
}
615+
}

0 commit comments

Comments
 (0)