Skip to content

Commit 7d7cab5

Browse files
committed
Merge pull request #137 from Jaykul/feature/fixfunctions
Fix function highligting
2 parents 3bad04c + 005e9ef commit 7d7cab5

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Support/PowershellSyntax.tmLanguage

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@
522522
<key>function</key>
523523
<dict>
524524
<key>begin</key>
525-
<string>((?i:function|filter|configuration|workflow))\s+((?:\p{L}|\d|_|-|\.)+)</string>
525+
<string>(?&lt;!\S)(?i)(function|filter|configuration|workflow)\s+(?:(global|local|script|private):)?((?:\p{L}|\d|_|-|\.)+)</string>
526526
<key>beginCaptures</key>
527527
<dict>
528528
<key>0</key>
@@ -538,7 +538,12 @@
538538
<key>2</key>
539539
<dict>
540540
<key>name</key>
541-
<string>entity.name.function</string>
541+
<string>storage.modifier.scope.powershell</string>
542+
</dict>
543+
<key>3</key>
544+
<dict>
545+
<key>name</key>
546+
<string>entity.name.function.powershell</string>
542547
</dict>
543548
</dict>
544549
<key>end</key>

tests/samples/test-file.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,3 +473,16 @@ function Get-EscapedPath
473473
return $path
474474
}
475475
}
476+
477+
#TODO: "function" should not be highlighted inside a command:
478+
# These three should highlight roughly the same:
479+
Test-Highlight -Something StringValue
480+
Move-Item .\AFolderForWorkflow .\ANew\Location
481+
Test-Function -StringFilter Pattern
482+
Test-Highlight -TestFunction StringValue
483+
function Test-Thing { <# When broken, only this comment wasn't broken #> }
484+
485+
# TODO: we should support scope on function names
486+
function global:Test-Thing { Get-Command $global:VariableName }
487+
function local:Test-Thing { Get-Command $global:VariableName }
488+
function script:Test-Thing { Get-Command $global:VariableName }

0 commit comments

Comments
 (0)