Skip to content

Commit f33f44c

Browse files
msftrncsTylerLeonhardt
authored andcommitted
Adds new PowerShell Core escapes e and u{x} (#60) (#171)
* Add `e and `u{x} escapes * add simple `e and `u{x}` tests
1 parent f1a9d6c commit f33f44c

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

PowerShellSyntax.tmLanguage

+25-1
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,14 @@
593593
<array>
594594
<dict>
595595
<key>match</key>
596-
<string>`[0abnfrvt"'$`]</string>
596+
<string>`[`0abefnrtv"'$]</string>
597597
<key>name</key>
598598
<string>constant.character.escape.powershell</string>
599599
</dict>
600+
<dict>
601+
<key>include</key>
602+
<string>#unicodeEscape</string>
603+
</dict>
600604
<dict>
601605
<key>match</key>
602606
<string>""</string>
@@ -605,6 +609,26 @@
605609
</dict>
606610
</array>
607611
</dict>
612+
<key>unicodeEscape</key>
613+
<dict>
614+
<key>comment</key>
615+
<string>`u{xxxx} added in PowerShell 6.0</string>
616+
<key>patterns</key>
617+
<array>
618+
<dict>
619+
<key>match</key>
620+
<string>`u\{(?:(?:10)?([0-9a-fA-F]){1,4}|0?\g&lt;1&gt;{1,5})}</string>
621+
<key>name</key>
622+
<string>constant.character.escape.powershell</string>
623+
</dict>
624+
<dict>
625+
<key>match</key>
626+
<string>`u(?:\{[0-9a-fA-F]{,6}.)?</string>
627+
<key>name</key>
628+
<string>invalid.character.escape.powershell</string>
629+
</dict>
630+
</array>
631+
</dict>
608632
<key>function</key>
609633
<dict>
610634
<key>begin</key>

spec/testfiles/syntax_test_TheBigTestFile.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -1198,9 +1198,9 @@ get-thing | Out-WithYou > $null # destroy
11981198
# ^ punctuation.definition.variable.powershell
11991199
# ^ constant.language.powershell
12001200
# ^ punctuation.definition.comment.powershell
1201-
"Escaped chars: `", `n, `$, `b, `t, `""
1201+
"Escaped chars: `", `n, `$, `b, `t, `e, `u{10ffff}, `""
12021202
# <- string.quoted.double.powershell
1203-
# ^^ ^^ ^^ ^^ ^^ ^^ string.quoted.double.powershell constant.character.escape.powershell
1203+
# ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^^ ^^ string.quoted.double.powershell constant.character.escape.powershell
12041204
'But here they''re not escape chars: `", `n, `$, `b, `"'
12051205
# ^^ constant.character.escape.powershell
12061206
# ^^ ^^ ^^ ^^ ^^ not:constant.character.escape.powershell

0 commit comments

Comments
 (0)