Skip to content

Commit a31aeb8

Browse files
committed
Support statement values (SublimeText#233)
See SublimeText#231
1 parent 1c38328 commit a31aeb8

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

PowerShell.sublime-syntax

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ contexts:
5757
- include: workflows
5858
- include: desired-state-configurations
5959

60-
- include: exceptions
61-
- include: loops
62-
- include: flow
63-
- include: conditionals
64-
6560
- match: \B\.(?= )
6661
scope: keyword.operator.source.powershell
6762
push:
@@ -73,6 +68,7 @@ contexts:
7368
- include: commands-quoted
7469
- include: else-pop
7570

71+
- include: flow
7672
- include: expressions
7773

7874
expressions:
@@ -86,6 +82,11 @@ contexts:
8682

8783
- include: escape-sequences
8884

85+
# Statements that may return values
86+
- include: exceptions
87+
- include: loops
88+
- include: conditionals
89+
8990
# Normal code
9091
- include: types
9192
- include: strings

tests/syntax_test_PowerShell.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,23 @@ using namespace System.Management.Automation
281281
# ^ punctuation.section.arguments.begin.powershell
282282
# ^ punctuation.section.arguments.end.powershell
283283

284+
# Statement value assignment
285+
$x = if ($a) { 1 } else { 2 }
286+
# ^^ keyword.control.conditional
287+
# ^^^^ keyword.control.conditional
288+
289+
$x = switch ($v) { 1 { 'one' } default { 'other' } }
290+
# ^^^^^^ keyword.control.conditional.switch
291+
292+
$x = foreach ($i in 1..3) { $i * 2 }
293+
# ^^^^^^^ keyword.control.loop
294+
295+
$x = try { Get-Thing } catch { $null }
296+
# ^^^ keyword.control.exception
297+
# @@@@@@@@@ reference
298+
# ^^^^^ keyword.control.exception
299+
300+
284301
# Hashtable
285302
$properties = @{
286303
# <- punctuation.definition.variable

0 commit comments

Comments
 (0)