Skip to content

Commit 4b2f3d5

Browse files
committed
Let pipe end the stop-parsing token
1 parent ea7133f commit 4b2f3d5

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

PowerShell.sublime-syntax

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ contexts:
8080
- include: requires-directives
8181

8282
- include: escape-sequences
83-
- include: stop-parsing-token
8483

8584
# Normal code
8685
- include: types
@@ -331,18 +330,21 @@ contexts:
331330
in-command:
332331
- meta_content_scope: meta.function-call.arguments.powershell
333332
- include: pop-end-of-command
333+
- include: stop-parsing-token
334334
- include: redirection
335335
- include: cli-parameters
336336
- include: expressions-without-commands
337337
- match: (?=\S)
338-
push:
339-
- meta_include_prototype: false
340-
- meta_scope: string.unquoted.powershell
341-
- match: (?=[\s#|>;,]|$)
342-
pop: 1
343-
- include: path-punctuation
344-
- include: escape-sequences
345-
- include: string-wildcards
338+
push: inside-unquoted-string
339+
340+
inside-unquoted-string:
341+
- meta_include_prototype: false
342+
- meta_scope: string.unquoted.powershell
343+
- match: (?=[\s#|>;,]|$)
344+
pop: 1
345+
- include: path-punctuation
346+
- include: escape-sequences
347+
- include: string-wildcards
346348

347349
pop-end-of-command:
348350
- include: line-continuations
@@ -381,6 +383,16 @@ contexts:
381383
2: punctuation.definition.parameter.powershell
382384
3: keyword.operator.assignment.powershell
383385

386+
stop-parsing-token:
387+
- match: \B--%\B
388+
scope: keyword.control.stop-parsing.powershell
389+
set:
390+
- meta_include_prototype: false
391+
- meta_scope: meta.function-call.arguments.powershell
392+
- meta_content_scope: string.unquoted.powershell
393+
- include: pop-before-eol
394+
- include: pop-pipe
395+
384396
###[ DIRECTIVES ]##############################################################
385397

386398
requires-directives:
@@ -1279,14 +1291,6 @@ contexts:
12791291

12801292
###[ COMPONENTS ]##############################################################
12811293

1282-
stop-parsing-token:
1283-
- match: \B--%\B
1284-
scope: keyword.control.powershell
1285-
push:
1286-
- meta_include_prototype: false
1287-
- meta_content_scope: string.unquoted.powershell
1288-
- include: pop-before-eol
1289-
12901294
path-punctuation:
12911295
- match: ':(?=[\\/])'
12921296
scope: punctuation.separator.path.powershell

tests/syntax_test_PowerShell.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,19 @@ using namespace System.Management.Automation
106106
# ^ punctuation.definition.parameter.powershell
107107
# ^^^^^^ variable.other.readwrite.powershell
108108
# ^ punctuation.definition.variable.powershell
109-
# ^^^ keyword.control.powershell
109+
# ^^^ keyword.control.stop-parsing.powershell
110110
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.unquoted.powershell
111111

112+
foo --% stop parsing until pipe | echo
113+
# ^^^ meta.function-call.powershell variable.function.powershell
114+
# @@@ reference
115+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
116+
# ^^^ keyword.control.stop-parsing.powershell
117+
# ^^^^^^^^^^^^^^^^^^^^^^^^^ string.unquoted.powershell
118+
# ^ keyword.operator.pipe.powershell
119+
# ^^^^ meta.function-call.powershell variable.function.powershell
120+
# @@@@ reference
121+
112122
& gnutool.exe -s 'short option' --long-option --very_long_option value +plus-option
113123
# ^ keyword.operator.call.powershell
114124
# ^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell

0 commit comments

Comments
 (0)