Skip to content

Commit db1a695

Browse files
committed
allow escape sequences outside strings (needed for 'argument mode' parsing)
--HG-- branch : next
1 parent bd84aa1 commit db1a695

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

Support/PowershellSyntax.JSON-tmLanguage

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"include": "#scriptblock"
4040
},
4141
{
42-
"begin": "(?<!\")\"",
42+
"begin": "(?<!(?<!`)\")\"",
4343
"end": "\"(?!\")",
4444
"name": "string.quoted.double.powershell",
4545
"patterns": [
@@ -58,6 +58,9 @@
5858
}
5959
]
6060
},
61+
{ "include": "#doubleQuotedStringEscapes",
62+
"comment": "Needed to parse stuff correctly in 'argument mode'. (See about_parsing.)"
63+
},
6164
{
6265
"begin": "(?<!')'",
6366
"end": "'(?!')",

Support/PowershellSyntax.tmLanguage

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</dict>
6969
<dict>
7070
<key>begin</key>
71-
<string>(?&lt;!")"</string>
71+
<string>(?&lt;!(?&lt;!`)")"</string>
7272
<key>end</key>
7373
<string>"(?!")</string>
7474
<key>name</key>
@@ -95,6 +95,12 @@
9595
</dict>
9696
</array>
9797
</dict>
98+
<dict>
99+
<key>comment</key>
100+
<string>Needed to parse stuff correctly in 'argument mode'. (See about_parsing.)</string>
101+
<key>include</key>
102+
<string>#doubleQuotedStringEscapes</string>
103+
</dict>
98104
<dict>
99105
<key>begin</key>
100106
<string>(?&lt;!')'</string>

bin/test-file.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<#
44
Let's see what embedded docs in comments look like...
55
TODO: inside here, .<tab> should present list of doc keywords
6-
6+
77
.synopsis
88
this is some text
99
@@ -49,6 +49,7 @@ string.'
4949
"Escaped chars: `", `n, `$, `b, `""
5050

5151
"""This is a string."""
52+
`""This is a string."`"
5253

5354
# Subexpressions cause powershell to reparse, so double quotes are ok.
5455
"String with embedded complex subexpression: $(get-item "$mypath/*.*" | out-string)."
@@ -65,7 +66,7 @@ string.'
6566
# FIXME: Wrong parens syled.
6667
"This is deeply nested: $( stuff-here | %{ why-would { $( ("you, do this anyway")) } } )"
6768

68-
"This string is
69+
"This string is
6970
valid"
7071

7172
"This string is `
@@ -74,7 +75,7 @@ valid but the ` is consumed."
7475
"This string is ``
7576
valid but the ` isn't consumed."
7677

77-
"This string is `
78+
"This string is `
7879
valid. There's a space at the end."
7980

8081
'This is a valid `
@@ -191,7 +192,7 @@ What the heck?
191192
"something $_"
192193
}
193194
"This should $a not be a {scriptblock}"
194-
{ this-is $(it-at | )
195+
{ this-is $(it-at | )
195196
}
196197

197198

0 commit comments

Comments
 (0)