Skip to content

Commit 8e35b8e

Browse files
committed
Recognize wildcards in unquoted strings
1 parent f3090e7 commit 8e35b8e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

PowerShell.sublime-syntax

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ contexts:
374374
pop: 1
375375
- include: path-punctuation
376376
- include: escape-sequences
377+
- include: string-wildcards
377378

378379
command-ending-sequences:
379380
- include: line-continuations
@@ -889,8 +890,9 @@ contexts:
889890
scope: keyword.operator.arithmetic.powershell
890891
- match: -(?![[:alpha:]-])
891892
scope: keyword.operator.arithmetic.powershell
892-
- match: \*
893+
- match: \*(?!\.?[[:alpha:]])
893894
scope: keyword.operator.arithmetic.powershell
895+
# Exclude foreach shortcut
894896
- match: '%(?!\s*\{)'
895897
scope: keyword.operator.arithmetic.powershell
896898
- match: \|\||&&
@@ -1115,6 +1117,12 @@ contexts:
11151117
- match: '[:,;]'
11161118
scope: punctuation.separator.powershell
11171119

1120+
string-wildcards:
1121+
- match: \*
1122+
scope: constant.other.wildcard.asterisk.powershell
1123+
- match: \?
1124+
scope: constant.other.wildcard.questionmark.powershell
1125+
11181126
numbers:
11191127
# Binary numbers
11201128
- match: \b(0[bB])([01]*)({{int_suffix}}?{{unit_suffix}}?)

Tests/syntax_test_PowerShell.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,9 @@ $a3[1..2]
924924
ls *.ps1 -recurse
925925
# ^^ meta.function-call.powershell variable.function.powershell
926926
# @@ reference
927-
# ^ keyword.operator.arithmetic.powershell
928-
# ^^^^ string.unquoted.powershell
927+
# ^^^^^ string.unquoted.powershell
928+
# ^ constant.other.wildcard.asterisk.powershell
929+
# ^ punctuation.separator.powershell
929930
# ^^^^^^^^ variable.parameter.option.powershell
930931
# ^ punctuation.definition.parameter.powershell
931932

0 commit comments

Comments
 (0)