Skip to content

Commit

Permalink
Escape characters are valid without string quoting
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelblyons committed Feb 1, 2020
1 parent d83caa6 commit 43a437b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 7 additions & 7 deletions PowerShell.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contexts:
- include: hashtable
- include: strings
- include: script-block
# - include: double-quoted-string-escapes
- include: escape-characters
- include: numeric-constant
- match: (@)(\()
captures:
Expand Down Expand Up @@ -204,7 +204,7 @@ contexts:
- include: variable-no-property
- include: hashtable
- include: script-block
- include: double-quoted-string-escapes
- include: escape-characters
- include: double-quoted-string
- include: type
- include: numeric-constant
Expand Down Expand Up @@ -281,7 +281,7 @@ contexts:
scope: punctuation.definition.string.end.powershell
pop: true
- include: variable-no-property
- include: double-quoted-string-escapes
- include: escape-characters
- include: interpolation
- match: \@'(?=$)
scope: punctuation.definition.string.begin.powershell
Expand Down Expand Up @@ -309,7 +309,9 @@ contexts:
scope: punctuation.definition.string.begin.powershell
push:
- meta_scope: string.quoted.double.powershell
- include: double-quoted-string-escapes
- match: '""'
scope: constant.character.escape.powershell
- include: escape-characters
- match: '"'
scope: punctuation.definition.string.end.powershell
pop: true
Expand All @@ -320,13 +322,11 @@ contexts:
- match: '`\s*$'
scope: keyword.other.powershell

double-quoted-string-escapes:
escape-characters:
- match: '`[0abenfrvt"''$`]'
scope: constant.character.escape.powershell
- match: '`u\{\h+\}'
scope: constant.character.escape.powershell
- match: '""'
scope: constant.character.escape.powershell

function:
- match: ^(?:\s*)(?i)(function|filter|configuration|workflow)\s+(?:(global|local|script|private):)?((?:\p{L}|\d|_|-|\.)+)
Expand Down
7 changes: 5 additions & 2 deletions Tests/syntax_test_PowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,7 @@ $This is a 'double quoted'
#^^^^ variable.language
Isn't it "nice"??
There is no @platting here!
# ^ - punctuation.definition.variable
# ^ - variable.other.readwrite
# ^^^^^^^^^ - variable - punctuation
"@
# <- string.quoted.double.heredoc
# <- string.quoted.double.heredoc
Expand Down Expand Up @@ -1306,6 +1305,10 @@ New-Object -TypeName System.Diagnostics.Process
# ^^^^^^^ - keyword.control
New-Object -TypeName System.Data
# ^^^^ - keyword.control
echo `"test`"
# ^^^^^^^^^ - string.quoted
# ^^ constant.character.escape
# ^^ constant.character.escape
@("any","array","has").foreach({ $_ })
# <- keyword.other.array.begin
# ^ meta.group.array-expression
Expand Down

0 comments on commit 43a437b

Please sign in to comment.