Skip to content

Commit 97ad5f6

Browse files
committed
Set in/out/ref to storage modifiers
1 parent 91d2c7f commit 97ad5f6

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

PowerShell.sublime-syntax

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,8 @@ contexts:
837837
- match: \]
838838
scope: punctuation.section.brackets.end.powershell
839839
pop: 1
840+
- match: \b(?:in|out|ref)\b
841+
scope: storage.modifier.powershell
840842
- match: \p{L}[\p{L}\p{N}]+(\.)
841843
scope: meta.generic-name.powershell
842844
captures:

tests/syntax_test_PowerShell.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,3 +2451,20 @@ function Process-DeploymentConfig {
24512451
Resolve-ConfigPath -Path "Foo" -PathVariables $PathVariables
24522452
# @@@@@@@@@@@@@@@@@@ reference
24532453
}
2454+
2455+
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_ref?view=powershell-7.6
2456+
# Create a value type variable.
2457+
$i = 0
2458+
# Create a reference type variable.
2459+
$iRef = [ref]0
2460+
# ^^^ storage.modifier.powershell
2461+
# Invoke a scriptblock to attempt to change both values.
2462+
&{$i++;$iRef.Value++}
2463+
# Output the results.
2464+
"`$i = $i;`$iRef = $($iRef.Value)"
2465+
2466+
[int]::TryParse("15", ([ref]$number))
2467+
# ^^^ storage.type.powershell
2468+
# ^^ punctuation.accessor.double-colon.powershell
2469+
# @@@@@@@@ reference
2470+
# ^^^ storage.modifier.powershell

0 commit comments

Comments
 (0)