Skip to content

Commit 3bc3e9c

Browse files
committed
Powershell: Add support for two levels of nested brackets inside namespace pattern. Fixes #1317
1 parent 8c3fa00 commit 3bc3e9c

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

components/prism-powershell.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Prism.languages.powershell = {
2727
}
2828
],
2929
// Matches name spaces as well as casts, attribute decorators. Force starting with letter to avoid matching array indices
30-
'namespace': /\[[a-z][\s\S]*?\]/i,
30+
// Supports two levels of nested brackets (e.g. `[OutputType([System.Collections.Generic.List[int]])]`)
31+
'namespace': /\[[a-z](?:\[(?:\[[^\]]*]|[^\[\]])*]|[^\[\]])*]/i,
3132
'boolean': /\$(?:true|false)\b/i,
3233
'variable': /\$\w+\b/i,
3334
// Cmdlets and aliases. Aliases should come last, otherwise "write" gets preferred over "write-host" for example

components/prism-powershell.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/powershell/namespace_feature.test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
[System.String]::Empty;
22
[Foo.Bar+Baz]::Abc;
33
[int] 42;
4+
[string[]]
5+
[OutputType([System.Collections.Generic.List[int]])]
46

57
----------------------------------------------------
68

79
[
810
["namespace", "[System.String]"],"::Empty",["punctuation", ";"],
911
["namespace", "[Foo.Bar+Baz]"],"::Abc",["punctuation", ";"],
10-
["namespace", "[int]"]," 42",["punctuation", ";"]
12+
["namespace", "[int]"]," 42",["punctuation", ";"],
13+
["namespace", "[string[]]"],
14+
["namespace", "[OutputType([System.Collections.Generic.List[int]])]"]
1115
]
1216
----------------------------------------------------
1317

0 commit comments

Comments
 (0)