diff --git a/PowerShellSyntax.tmLanguage b/PowerShellSyntax.tmLanguage
index 43adbba..ea85f28 100644
--- a/PowerShellSyntax.tmLanguage
+++ b/PowerShellSyntax.tmLanguage
@@ -1042,7 +1042,7 @@
0
name
- support.constant.automatic.powershell
+ support.variable.automatic.powershell
1
@@ -1058,7 +1058,7 @@
comment
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.
match
- (\$)(?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
+ (\$)((?:[$^?])|(?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)?
captures
@@ -1342,7 +1342,7 @@
comment
Automatic variables are not constants, but they are read-only...
match
- (\$)(?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
+ (\$)((?:[$^?])|(?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)
captures
diff --git a/spec/testfiles/syntax_test_Class.ps1 b/spec/testfiles/syntax_test_Class.ps1
index 662c488..27db15c 100644
--- a/spec/testfiles/syntax_test_Class.ps1
+++ b/spec/testfiles/syntax_test_Class.ps1
@@ -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
@@ -110,7 +110,7 @@ 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
@@ -118,7 +118,7 @@ class TypeName
return $this.P3
# <- keyword.control.powershell
# ^ punctuation.definition.variable.powershell
- # ^^^^ support.constant.automatic.powershell
+ # ^^^^ support.variable.automatic.powershell
# ^^ variable.other.member.powershell
}
}
diff --git a/spec/testfiles/syntax_test_Function.ps1 b/spec/testfiles/syntax_test_Function.ps1
index c297d21..187dab1 100644
--- a/spec/testfiles/syntax_test_Function.ps1
+++ b/spec/testfiles/syntax_test_Function.ps1
@@ -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
@@ -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
diff --git a/spec/testfiles/syntax_test_TheBigTestFile.ps1 b/spec/testfiles/syntax_test_TheBigTestFile.ps1
index 340e685..7d16fbf 100644
--- a/spec/testfiles/syntax_test_TheBigTestFile.ps1
+++ b/spec/testfiles/syntax_test_TheBigTestFile.ps1
@@ -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
@@ -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
@@ -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
@@ -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