Skip to content

Commit 8a4b6f9

Browse files
committed
Rescope pipes again
1 parent 41621a3 commit 8a4b6f9

File tree

2 files changed

+36
-18
lines changed

2 files changed

+36
-18
lines changed

PowerShell.sublime-syntax

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,18 @@ contexts:
383383
pop: 1
384384

385385
pop-pipe:
386-
- match: (\|)\s*\n
386+
- match: (?:(\|)|(\|\||&&))\s*\n
387387
captures:
388-
1: keyword.operator.assignment.pipe.powershell
388+
1: keyword.operator.pipe.powershell
389+
2: keyword.operator.pipe.conditional.powershell
389390
push:
390391
- match: ^
391392
pop: 2
393+
- match: \|\||&&
394+
scope: keyword.operator.pipe.conditional.powershell
395+
pop: 1
392396
- match: \|
393-
scope: keyword.operator.assignment.pipe.powershell
397+
scope: keyword.operator.pipe.powershell
394398
pop: 1
395399

396400
cli-parameters:
@@ -899,14 +903,18 @@ contexts:
899903
1: punctuation.definition.keyword.powershell
900904

901905
operator-symbols:
902-
# Assignment context
906+
# Pipes
907+
- match: \|\||&&
908+
scope: keyword.operator.pipe.conditional.powershell
909+
- match: \|
910+
scope: keyword.operator.pipe.powershell
911+
912+
# Assignment with context
903913
- include: assignment-normal
904914
- match: (?:[+/*%-]|\?\?)=
905915
scope: keyword.operator.assignment.augmented.powershell
906916
push: in-assignment
907917
# Assignment same context
908-
- match: \|
909-
scope: keyword.operator.assignment.pipe.powershell
910918
- match: (?:\+\+|--)(?![ \t]*\d|[[:alpha:]])
911919
scope: keyword.operator.assignment.powershell
912920

@@ -928,8 +936,6 @@ contexts:
928936

929937
- match: \!
930938
scope: keyword.operator.logical.powershell
931-
- match: \|\||&&
932-
scope: keyword.operator.logical.powershell
933939
- match: \?\?
934940
scope: keyword.operator.null-coalescing.powershell
935941
- match: '[?:]'

Tests/syntax_test_PowerShell.ps1

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ $a3[1..2]
880880
# ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
881881
# ^^ keyword.operator.range.powershell
882882
# ^^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
883-
# ^ keyword.operator.assignment.pipe.powershell
883+
# ^ keyword.operator.pipe.powershell
884884
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
885885
# @@@@@@@@@@@@@@@@ reference
886886
# ^ punctuation.section.group.end.powershell
@@ -899,7 +899,7 @@ $a3[1..2]
899899
# ^^^ variable.parameter.option.powershell
900900
# ^ punctuation.definition.parameter.powershell
901901
# ^^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
902-
# ^ keyword.operator.assignment.pipe.powershell
902+
# ^ keyword.operator.pipe.powershell
903903
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
904904
# @@@@@@@@@@@@@@@@ reference
905905
# ^^^^^^^^ meta.function-call.arguments.powershell
@@ -926,7 +926,7 @@ $a3[1..2]
926926
#^^^^^^^^^ meta.function-call.arguments.powershell
927927
#^^^^^^^^ meta.block.powershell
928928
# ^ punctuation.section.braces.end.powershell
929-
# ^ keyword.operator.assignment.pipe.powershell
929+
# ^ keyword.operator.pipe.powershell
930930
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
931931
# @@@@@@@@@@@@@@@@ reference
932932

@@ -952,7 +952,7 @@ $a3[1..2]
952952
# ^ punctuation.definition.parameter.powershell
953953
# ^^^^^^ variable.other.readwrite.powershell
954954
# ^ punctuation.definition.variable.powershell
955-
# ^ keyword.operator.assignment.pipe.powershell
955+
# ^ keyword.operator.pipe.powershell
956956
# ^^^^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
957957
# @@@@@@@@@@@@@@@@ reference
958958
# ^^^^^^^^^ meta.function-call.arguments.powershell
@@ -963,7 +963,7 @@ $a3[1..2]
963963
# ^^^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
964964
# @@@@@@@@@@@@@ reference
965965
# ^^ meta.function-call.arguments.powershell
966-
# ^ keyword.operator.assignment.pipe.powershell
966+
# ^ keyword.operator.pipe.powershell
967967
Select Name,Length
968968
# ^^^^^^ meta.function-call.powershell variable.function.powershell
969969
# @@@@@@ reference
@@ -972,6 +972,18 @@ $a3[1..2]
972972
# ^ punctuation.separator.sequence.powershell
973973
# ^^^^^^ string.unquoted.powershell
974974

975+
Do-Something && ContinueOn-Success || ContinueOn-Failure
976+
# ^^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
977+
# @@@@@@@@@@@@ reference
978+
# ^ meta.function-call.arguments.powershell
979+
# ^^ keyword.operator.pipe.conditional.powershell
980+
# ^^^^^^^^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
981+
# @@@@@@@@@@@@@@@@@@ reference
982+
# ^ meta.function-call.arguments.powershell
983+
# ^^ keyword.operator.pipe.conditional.powershell
984+
# ^^^^^^^^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
985+
# @@@@@@@@@@@@@@@@@@ reference
986+
975987
# Commands (Built-in variables)
976988
ls *.ps1 -recurse
977989
# ^^ meta.function-call.powershell variable.function.powershell
@@ -1341,7 +1353,7 @@ $a3[1..2]
13411353
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell
13421354
# ^^^^^^ variable.other.readwrite.powershell
13431355
# ^ punctuation.definition.variable.powershell
1344-
# ^ keyword.operator.assignment.pipe.powershell
1356+
# ^ keyword.operator.pipe.powershell
13451357
# ^ meta.function-call.powershell variable.function.powershell
13461358
# @ reference
13471359
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
@@ -1358,7 +1370,7 @@ $a3[1..2]
13581370
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell
13591371
# ^^^^^^ variable.other.readwrite.powershell
13601372
# ^ punctuation.definition.variable.powershell
1361-
# ^ keyword.operator.assignment.pipe.powershell
1373+
# ^ keyword.operator.pipe.powershell
13621374
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
13631375
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ reference
13641376
# ^^^^^^^ meta.function-call.arguments.powershell
@@ -1984,7 +1996,7 @@ $a3[1..2]
19841996
$ScriptBlock | Out-File $file -Force
19851997
# ^^^^^^^^^^^^ variable.other.readwrite.powershell
19861998
# ^ punctuation.definition.variable.powershell
1987-
# ^ keyword.operator.assignment.pipe.powershell
1999+
# ^ keyword.operator.pipe.powershell
19882000
# ^^^^^^^^ meta.function-call.powershell support.function.powershell
19892001
# @@@@@@@@ reference
19902002
# ^^^^^^^^^^^^^ meta.function-call.arguments.powershell
@@ -2010,7 +2022,7 @@ $a3[1..2]
20102022
# ^^^^^^^^^ meta.function-call.powershell support.function.powershell
20112023
# @@@@@@@@@ reference
20122024
# ^ meta.function-call.arguments.powershell
2013-
# ^ keyword.operator.assignment.pipe.powershell
2025+
# ^ keyword.operator.pipe.powershell
20142026
# ^^^^^^^^^^^ meta.function-call.powershell support.function.powershell
20152027
# @@@@@@@@@@@ reference
20162028
# ^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
@@ -2037,7 +2049,7 @@ $a3[1..2]
20372049
# ^^^^^^^^^^ meta.function-call.powershell support.function.powershell
20382050
# @@@@@@@@@@ reference
20392051
# ^ meta.function-call.arguments.powershell
2040-
# ^ keyword.operator.assignment.pipe.powershell
2052+
# ^ keyword.operator.pipe.powershell
20412053
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.powershell
20422054
# ^ keyword.control.loop.for.powershell
20432055
# ^ punctuation.section.braces.begin.powershell

0 commit comments

Comments
 (0)