diff --git a/PowerShell.sublime-syntax b/PowerShell.sublime-syntax index 8d1941b..ad864df 100644 --- a/PowerShell.sublime-syntax +++ b/PowerShell.sublime-syntax @@ -75,6 +75,11 @@ contexts: - include: main - match: \b[\w.-]+\.(?i:exe|com|cmd|bat)\b scope: variable.function.powershell + # Consume a string with a trailing dot + # to prevent members with particular names from being recognized as keywords. + - match: \b[\w-]+(?=\.) + scope: variable.other.object.powershell + push: members # Exceptions - match: \b(?i:throw){{kebab_break}} scope: keyword.control.exception.raise.powershell @@ -100,6 +105,8 @@ contexts: # Begin/End - match: \b(?i:begin){{kebab_break}} scope: keyword.context.block.begin.powershell + - match: \b(?i:process){{kebab_break}} + scope: keyword.context.block.process.powershell - match: \b(?i:end){{kebab_break}} scope: keyword.context.block.end.powershell - match: \b(?i:clean){{kebab_break}} @@ -129,7 +136,7 @@ contexts: - match: \b(?i:(?:dynamic)?param){{kebab_break}} scope: keyword.declaration.parameter.powershell # This scope is not standard # Uncategorized keywords - - match: \b(?i:data|default|define|from|in|inlinescript|parallel|process){{kebab_break}} + - match: \b(?i:data|default|define|from|in|inlinescript|parallel|sequence){{kebab_break}} scope: keyword.control.powershell - match: \B--%\B scope: keyword.control.powershell @@ -292,10 +299,10 @@ contexts: (?xi: \b( Mandatory | ValueFromPipeline(?:ByPropertyName)? - | ValueFromRemainingArguments | Position + | ValueFromRemainingArguments | Position(?:alBinding)? | (?:Default)?ParameterSetName | SupportsShouldProcess | SupportsPaging - | PositionalBinding | HelpUri | ConfirmImpact | HelpMessage - ) + | HelpUri | ConfirmImpact | HelpMessage + )\b \s*(=)? ) captures: diff --git a/Tests/syntax_test_Function.ps1 b/Tests/syntax_test_Function.ps1 index 3c16339..6688d66 100644 --- a/Tests/syntax_test_Function.ps1 +++ b/Tests/syntax_test_Function.ps1 @@ -376,7 +376,7 @@ function Verb-Noun { { } Process { - # <- keyword.control + # <- keyword.context.block.process if ($pscmdlet.ShouldProcess("Target", "Operation")) { # <- keyword.control # ^ punctuation.section.group.begin diff --git a/Tests/syntax_test_PowerShell.ps1 b/Tests/syntax_test_PowerShell.ps1 index c9b7626..b882559 100644 --- a/Tests/syntax_test_PowerShell.ps1 +++ b/Tests/syntax_test_PowerShell.ps1 @@ -1360,6 +1360,12 @@ New-Object -TypeName System.Diagnostics.Process # ^^^^^^^ - keyword.control New-Object -TypeName System.Data # ^^^^ - keyword.control +New-Object -TypeName Sy-stem.if +# ^^ - keyword.control +New-Object -TypeName S_ystem.Clean +# ^^^^^ - keyword.control +New-Object -TypeName Sy_stem-.Throw +# ^^^^^ - keyword.control echo `"test`" # ^^^^^^^^^ - string.quoted # ^^ constant.character.escape