Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions PowerShell.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ 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-]+(?=\.)
push: members
# Exceptions
- match: \b(?i:throw){{kebab_break}}
scope: keyword.control.exception.raise.powershell
Expand All @@ -100,6 +104,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}}
Expand Down Expand Up @@ -129,7 +135,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
Expand Down Expand Up @@ -292,9 +298,9 @@ contexts:
(?xi:
\b(
Mandatory | ValueFromPipeline(?:ByPropertyName)?
| ValueFromRemainingArguments | Position
| ValueFromRemainingArguments | Position(?:alBinding)?
| (?:Default)?ParameterSetName | SupportsShouldProcess | SupportsPaging
| PositionalBinding | HelpUri | ConfirmImpact | HelpMessage
| HelpUri | ConfirmImpact | HelpMessage
)
\s*(=)?
)
Expand Down
2 changes: 1 addition & 1 deletion Tests/syntax_test_Function.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Tests/syntax_test_PowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@
# ^^ constant.numeric.float
1.d
# ^^^ constant.numeric.float
1.lGB

Check failure on line 478 in Tests/syntax_test_PowerShell.ps1

View workflow job for this annotation

GitHub Actions / Syntax Tests (4102)

[constant.numeric.float - unclear whether float or int] does not match scope [source.powershell]

Check failure on line 478 in Tests/syntax_test_PowerShell.ps1

View workflow job for this annotation

GitHub Actions / Syntax Tests (4102)

[keyword.other.unit] does not match scope [source.powershell]

Check failure on line 478 in Tests/syntax_test_PowerShell.ps1

View workflow job for this annotation

GitHub Actions / Syntax Tests (4102)

[keyword.other.unit] does not match scope [source.powershell]
# ^^^ constant.numeric.float - unclear whether float or int
# ^^ keyword.other.unit
1.dGB
Expand Down Expand Up @@ -522,7 +522,7 @@
# ^^ constant.numeric.integer
# ^^^ constant.numeric.float
# ^ keyword.operator
-10.002L

Check failure on line 525 in Tests/syntax_test_PowerShell.ps1

View workflow job for this annotation

GitHub Actions / Syntax Tests (4102)

[constant.numeric.float - unclear whether float or int] does not match scope [source.powershell]
# ^ keyword.operator.unary
# ^^^^^^^ constant.numeric.float - unclear whether float or int
$x..5.40D
Expand Down Expand Up @@ -1360,6 +1360,12 @@
# ^^^^^^^ - 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
Expand Down
Loading