Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions PowerShellSyntax.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@
<key>0</key>
<dict>
<key>name</key>
<string>support.constant.automatic.powershell</string>
<string>support.variable.automatic.powershell</string>
</dict>
<key>1</key>
<dict>
Expand All @@ -1058,7 +1058,7 @@
<key>comment</key>
<string>Automatic variables are not constants, but they are read-only. In monokai (default) color schema support.variable doesn't have color, so we use constant.</string>
<key>match</key>
<string>(\$)(?i:(\$|\^|\?|_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This))((?:\.(?:\p{L}|\d|_)+)*\b)?\b</string>
<string>(\$)((?:[$^?])|(?i:_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\b)((?:\.(?:\p{L}|\d|_)+)*\b)?</string>
</dict>
<dict>
<key>captures</key>
Expand Down Expand Up @@ -1342,7 +1342,7 @@
<key>comment</key>
<string>Automatic variables are not constants, but they are read-only...</string>
<key>match</key>
<string>(\$)(?i:(\$|\^|\?|_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This))\b</string>
<string>(\$)((?:[$^?])|(?i:_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\b)</string>
</dict>
<dict>
<key>captures</key>
Expand Down
6 changes: 3 additions & 3 deletions spec/testfiles/syntax_test_Class.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class TypeName
# ^ punctuation.section.group.end.powershell
$this.P1 = $s
# <- punctuation.definition.variable.powershell
# ^ support.constant.automatic.powershell
# ^ support.variable.automatic.powershell
# ^^ variable.other.member.powershell
# ^ keyword.operator.assignment.powershell
# ^ punctuation.definition.variable.powershell
Expand Down Expand Up @@ -110,15 +110,15 @@ class TypeName
# ^ punctuation.section.group.end.powershell
$this.P3 = $i
# <- punctuation.definition.variable.powershell
# ^ support.constant.automatic.powershell
# ^ support.variable.automatic.powershell
# ^^ variable.other.member.powershell
# ^ keyword.operator.assignment.powershell
# ^ punctuation.definition.variable.powershell
# ^ variable.other.readwrite.powershell
return $this.P3
# <- keyword.control.powershell
# ^ punctuation.definition.variable.powershell
# ^^^^ support.constant.automatic.powershell
# ^^^^ support.variable.automatic.powershell
# ^^ variable.other.member.powershell
}
}
4 changes: 2 additions & 2 deletions spec/testfiles/syntax_test_Function.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function Verb-Noun {
# ^ meta.attribute.powershell meta.scriptblock.powershell
# ^^^^^^^^^ meta.scriptblock.powershell support.function.powershell
# ^ meta.scriptblock.powershell punctuation.definition.variable.powershell
# ^ meta.scriptblock.powershell support.constant.automatic.powershell
# ^ meta.scriptblock.powershell support.variable.automatic.powershell
# ^ meta.attribute.powershell meta.scriptblock.powershell
# ^ meta.attribute.powershell punctuation.section.group.end.powershell
# ^ meta.attribute.powershell punctuation.section.bracket.end.powershell
Expand Down Expand Up @@ -359,7 +359,7 @@ function Verb-Noun {
# <- keyword.control.powershell
# ^ punctuation.section.group.begin.powershell
# ^ punctuation.definition.variable.powershell
# ^^^^^^^^ support.constant.automatic.powershell
# ^^^^^^^^ support.variable.automatic.powershell
# ^^^^^^^^^^^^^ variable.other.member.powershell
# ^ punctuation.section.group.begin.powershell
# ^ punctuation.section.group.end.powershell
Expand Down
22 changes: 17 additions & 5 deletions spec/testfiles/syntax_test_TheBigTestFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,18 @@ throw "Do not run this file!"
# ^^ ^^ ^^ ^^ ^ ^ string.unquoted.powershell

# Automatic variables
$_
$_, $$, $^, $?
# <- punctuation.definition.variable.powershell
# <- support.constant.automatic.powershell
# <- support.variable.automatic.powershell
# ^ punctuation.definition.variable.powershell
# ^ support.variable.automatic.powershell
# ^ punctuation.definition.variable.powershell
# ^ support.variable.automatic.powershell
# ^ punctuation.definition.variable.powershell
# ^ support.variable.automatic.powershell
$args
# <- punctuation.definition.variable.powershell
# ^ support.constant.automatic.powershell
# ^ support.variable.automatic.powershell
$error
# <- punctuation.definition.variable.powershell
# ^ support.constant.variable.powershell
Expand All @@ -103,7 +109,7 @@ $home
# ^ support.constant.variable.powershell
$foreach
# <- punctuation.definition.variable.powershell
# ^ support.constant.automatic.powershell
# ^ support.variable.automatic.powershell

# Normal variables
$variable
Expand Down Expand Up @@ -179,6 +185,12 @@ $variable.Name
# ^ not:punctuation.definition.variable.powershell
# ^ not:variable.other.readwrite.powershell

# double check scopes for automatic variables in strings
"$_ $$ $Pwd"
# ^ support.variable.automatic.powershell
# ^ support.variable.automatic.powershell
# ^ support.variable.automatic.powershell

# Single quotes string
'This is a string'
# <- punctuation.definition.string.begin.powershell string.quoted.single.powershell
Expand Down Expand Up @@ -912,7 +924,7 @@ class Vehicle {
# ^ variable.other.readwrite.powershell
$this.Mileage += $NumberOfMiles
# ^ punctuation.definition.variable.powershell
# ^^^^ support.constant.automatic.powershell
# ^^^^ support.variable.automatic.powershell
# ^ variable.other.member.powershell
# ^^ keyword.operator.assignment.powershell

Expand Down