Skip to content

Commit eb57ab0

Browse files
committed
Use better patterns for path punctuation
1 parent a514523 commit eb57ab0

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

PowerShell.sublime-syntax

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,16 @@ contexts:
12961296
- include: pop-before-eol
12971297

12981298
path-punctuation:
1299-
- match: '[:/\\.]+'
1300-
scope: punctuation.separator.powershell
1299+
- match: ':(?=[\\/])'
1300+
scope: punctuation.separator.path.powershell
1301+
- match: \.\.(?=[\\/])
1302+
scope: constant.other.path.parent.powershell
1303+
- match: \.(?=[\\/])
1304+
scope: constant.other.path.self.powershell
1305+
- match: ~(?=[\\/])
1306+
scope: variable.language.tilde.powershell
1307+
- match: '[\\/]+'
1308+
scope: punctuation.separator.path.powershell
13011309

13021310
line-continuations:
13031311
- match: (`)\n

Tests/syntax_test_PowerShell.ps1

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,6 @@ $a3[1..2]
978978
# @@ reference
979979
# ^^^^^ string.unquoted.powershell
980980
# ^ constant.other.wildcard.asterisk.powershell
981-
# ^ punctuation.separator.powershell
982981
# ^^^^^^^^ variable.parameter.option.powershell
983982
# ^ punctuation.definition.parameter.powershell
984983

@@ -1008,20 +1007,20 @@ $a3[1..2]
10081007

10091008
& '.\script name with spaces.ps1'
10101009
# ^ keyword.operator.call.powershell
1011-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.powershell string.quoted.single.powershell meta.function-call.powershell variable.function.powershell
1010+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell meta.string.powershell string.quoted.single.powershell meta.function-call.powershell variable.function.powershell
10121011
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ reference
10131012
# ^ punctuation.definition.string.begin.powershell
1014-
# ^^ punctuation.separator.powershell
1015-
# ^ punctuation.separator.powershell
1013+
# ^ constant.other.path.self.powershell
1014+
# ^ punctuation.separator.path.powershell
10161015
# ^ punctuation.definition.string.end.powershell
10171016

10181017
& ".\script name with spaces.ps1"
10191018
# ^ keyword.operator.call.powershell
1020-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell meta.function-call.powershell variable.function.powershell
1019+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell meta.string.interpolated.powershell string.quoted.double.powershell meta.function-call.powershell variable.function.powershell
10211020
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ reference
10221021
# ^ punctuation.definition.string.begin.powershell
1023-
# ^^ punctuation.separator.powershell
1024-
# ^ punctuation.separator.powershell
1022+
# ^ constant.other.path.self.powershell
1023+
# ^ punctuation.separator.path.powershell
10251024
# ^ punctuation.definition.string.end.powershell
10261025

10271026
# switch
@@ -1086,7 +1085,8 @@ $a3[1..2]
10861085
# ^^^^^ variable.parameter.option.powershell
10871086
# ^ punctuation.definition.parameter.powershell
10881087
# ^^^^^^^^^^^^^^ string.unquoted.powershell
1089-
# ^^ punctuation.separator.powershell
1088+
# ^ constant.other.path.self.powershell
1089+
# ^ punctuation.separator.path.powershell
10901090
# ^^ meta.block.powershell
10911091
# ^ punctuation.section.braces.begin.powershell
10921092
# ^ punctuation.section.braces.end.powershell
@@ -1336,11 +1336,11 @@ $a3[1..2]
13361336
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
13371337
# ^ keyword.operator.ternary.powershell
13381338
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.unquoted.powershell
1339-
# ^ punctuation.separator.powershell
1340-
# ^ punctuation.separator.powershell
1341-
# ^ punctuation.separator.powershell
1342-
# ^ punctuation.separator.powershell
1343-
# ^ punctuation.separator.powershell
1339+
# ^ punctuation.separator.path.powershell
1340+
# ^ punctuation.separator.path.powershell
1341+
# ^ punctuation.separator.path.powershell
1342+
# ^ punctuation.separator.path.powershell
1343+
# ^ punctuation.separator.path.powershell
13441344
# ^^^^^^^^^^^^^^^^^ comment.line.powershell
13451345
# ^ punctuation.definition.comment.powershell
13461346
$roman | c:\users\Me\Documents\Programming\F\test.exe $roman
@@ -1685,21 +1685,18 @@ $a3[1..2]
16851685
# @@@@@@@@@@@ reference
16861686
# ^ keyword.operator.redirection.powershell
16871687
# ^^^^^^^ string.unquoted.powershell
1688-
# ^ punctuation.separator.powershell
16891688
notepad.exe 1> log.txt
16901689
# ^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
16911690
# @@@@@@@@@@@ reference
16921691
# ^ constant.numeric.decimal.file-descriptor.powershell
16931692
# ^ keyword.operator.redirection.powershell
16941693
# ^^^^^^^ string.unquoted.powershell
1695-
# ^ punctuation.separator.powershell
16961694
notepad.exe *> log.txt
16971695
# ^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
16981696
# @@@@@@@@@@@ reference
16991697
# ^ constant.numeric.decimal.file-descriptor.powershell
17001698
# ^ keyword.operator.redirection.powershell
17011699
# ^^^^^^^ string.unquoted.powershell
1702-
# ^ punctuation.separator.powershell
17031700
notepad.exe 2>&1
17041701
# ^^^^^^^^^^^ meta.function-call.powershell variable.function.powershell
17051702
# @@@@@@@@@@@ reference
@@ -1738,7 +1735,6 @@ $a3[1..2]
17381735
# ^ constant.numeric.decimal.file-descriptor.powershell
17391736
# ^ keyword.operator.redirection.powershell
17401737
# ^^^^^^^ string.unquoted.powershell
1741-
# ^ punctuation.separator.powershell
17421738

17431739
# Operators
17441740
if (10 -cgt 100) { }
@@ -2080,8 +2076,6 @@ $a3[1..2]
20802076
# ^^^^^^^^^ variable.parameter.option.powershell
20812077
# ^ punctuation.definition.parameter.powershell
20822078
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ string.unquoted.powershell - keyword
2083-
# ^ punctuation.separator.powershell
2084-
# ^ punctuation.separator.powershell
20852079
New-Object -TypeName System.Data
20862080
# ^^^^^^^^^^ meta.function-call.powershell support.function.powershell
20872081
# @@@@@@@@@@ reference
@@ -2094,14 +2088,12 @@ $a3[1..2]
20942088
# ^^^^^^^^^ variable.parameter.option.powershell
20952089
# ^ punctuation.definition.parameter.powershell
20962090
# ^^^^^^^^^^ string.unquoted.powershell - keyword
2097-
# ^ punctuation.separator.powershell
20982091
New-Object -TypeName S_ystem.Clean
20992092
# ^^^^^^^^^^ meta.function-call.powershell support.function.powershell
21002093
# @@@@@@@@@@ reference
21012094
# ^^^^^^^^^ variable.parameter.option.powershell
21022095
# ^ punctuation.definition.parameter.powershell
21032096
# ^^^^^^^^^^^^^ string.unquoted.powershell - keyword
2104-
# ^ punctuation.separator.powershell
21052097
New-Object -TypeName Sy_stem-.Throw
21062098
# ^^^^^^^^^^ meta.function-call.powershell support.function.powershell
21072099
# @@@@@@@@@@ reference

0 commit comments

Comments
 (0)