Skip to content

Commit a559d9a

Browse files
committed
Mark scripts as functions after & or .
Even if they are quoted.
1 parent e9fbfd8 commit a559d9a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

PowerShell.sublime-syntax

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ contexts:
5858

5959
- match: \B\.(?= )
6060
scope: keyword.operator.source.powershell
61+
push:
62+
- include: commands-quoted
63+
- include: else-pop
6164
- match: \&
6265
scope: keyword.operator.call.powershell
66+
push:
67+
- include: commands-quoted
68+
- include: else-pop
6369

6470
- include: expressions
6571

@@ -310,6 +316,22 @@ contexts:
310316
scope: meta.function-call.powershell variable.function.powershell
311317
push: in-command
312318

319+
commands-quoted:
320+
- match: (?={{single_quote}})
321+
push: [in-command, expect-single-quoted-command]
322+
- match: (?={{double_quote}})
323+
push: [in-command, expect-double-quoted-command]
324+
325+
expect-single-quoted-command:
326+
- meta_scope: meta.function-call.powershell variable.function.powershell
327+
- include: single-quoted-strings
328+
- include: immediately-pop
329+
330+
expect-double-quoted-command:
331+
- meta_scope: meta.function-call.powershell variable.function.powershell
332+
- include: double-quoted-strings
333+
- include: immediately-pop
334+
313335
command-freeform:
314336
- match: '{{identifier_simple}}'
315337
scope: meta.function-call.powershell variable.function.powershell

Tests/syntax_test_PowerShell.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,13 @@ $a3[1..2]
922922
# ^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
923923
# @@@@@@@@@@ reference
924924

925+
& ".\script name with spaces.ps1"
926+
# ^ keyword.operator.call.powershell
927+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell meta.string.interpolated.powershell string.quoted.double.powershell
928+
# ^ punctuation.definition.string.begin.powershell
929+
# ^ punctuation.definition.string.end.powershell
930+
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ reference
931+
925932
# switch
926933
switch ("fourteen") {}
927934
# <- keyword.control

0 commit comments

Comments
 (0)