diff --git a/PowerShell.sublime-syntax b/PowerShell.sublime-syntax index 9a0eb2a..8979372 100644 --- a/PowerShell.sublime-syntax +++ b/PowerShell.sublime-syntax @@ -57,11 +57,6 @@ contexts: - include: workflows - include: desired-state-configurations - - include: exceptions - - include: loops - - include: flow - - include: conditionals - - match: \B\.(?= ) scope: keyword.operator.source.powershell push: @@ -73,6 +68,7 @@ contexts: - include: commands-quoted - include: else-pop + - include: flow - include: expressions expressions: @@ -86,6 +82,11 @@ contexts: - include: escape-sequences + # Statements that may return values + - include: exceptions + - include: loops + - include: conditionals + # Normal code - include: types - include: strings diff --git a/tests/syntax_test_PowerShell.ps1 b/tests/syntax_test_PowerShell.ps1 index 015ce41..5929af5 100644 --- a/tests/syntax_test_PowerShell.ps1 +++ b/tests/syntax_test_PowerShell.ps1 @@ -281,6 +281,23 @@ using namespace System.Management.Automation # ^ punctuation.section.arguments.begin.powershell # ^ punctuation.section.arguments.end.powershell + # Statement value assignment + $x = if ($a) { 1 } else { 2 } +# ^^ keyword.control.conditional +# ^^^^ keyword.control.conditional + + $x = switch ($v) { 1 { 'one' } default { 'other' } } +# ^^^^^^ keyword.control.conditional.switch + + $x = foreach ($i in 1..3) { $i * 2 } +# ^^^^^^^ keyword.control.loop + + $x = try { Get-Thing } catch { $null } +# ^^^ keyword.control.exception +# @@@@@@@@@ reference +# ^^^^^ keyword.control.exception + + # Hashtable $properties = @{ # <- punctuation.definition.variable