Skip to content

Commit 41621a3

Browse files
committed
Tighten function name restrictions
1 parent d916071 commit 41621a3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

PowerShell.sublime-syntax

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ contexts:
349349
- include: path-punctuation
350350

351351
command-freeform:
352-
- match: '{{identifier_simple}}'
352+
- match: '{{identifier_function}}'
353353
scope: meta.function-call.powershell variable.function.powershell
354354
push: in-command
355355

@@ -1396,7 +1396,7 @@ variables:
13961396
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_variables
13971397
identifier_simple: '[\p{L}\p{Nd}_?]+'
13981398
identifier_special: '[^}]*[^}`]'
1399-
identifier_function: '[\p{L}\p{Nd}_.-]+'
1399+
identifier_function: '[\p{L}_][\p{L}\p{Nd}_.-]*\b'
14001400
identifier_csharp: '[\p{L}_][\p{L}\p{Nd}_]*'
14011401
var_lookahead: |-
14021402
(?x: (?=

Tests/syntax_test_PowerShell.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,17 @@ $a3[1..2]
981981
# ^^^^^^^^ variable.parameter.option.powershell
982982
# ^ punctuation.definition.parameter.powershell
983983

984+
# Issue 164
985+
Do-Cleanup
986+
# ^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
987+
# @@@@@@@@@@ reference
988+
If-Thing
989+
# ^^^^^^^^ meta.function-call.powershell variable.function.powershell
990+
# @@@@@@@@ reference
991+
Something-Else
992+
# ^^^^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
993+
# @@@@@@@@@@@@@@ reference
994+
984995
# Commands (executable files)
985996
. .\scripts\Test-Foo.ps1 -parameter 'value'
986997
# ^ keyword.operator.source.powershell

0 commit comments

Comments
 (0)