Skip to content

Commit 9ecdc80

Browse files
committed
Revise region-matching regexes and add new fold scopes
1 parent 1213df6 commit 9ecdc80

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

Fold.tmPreferences

+22-2
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,41 @@
99
<array>
1010
<dict>
1111
<key>begin</key>
12-
<string>punctuation.section.block.begin</string>
12+
<string>meta.fold.begin</string>
1313
<key>end</key>
14-
<string>punctuation.section.block.end</string>
14+
<string>meta.fold.end</string>
1515
</dict>
1616
<dict>
1717
<key>begin</key>
1818
<string>punctuation.definition.comment.block.begin</string>
1919
<key>end</key>
2020
<string>punctuation.definition.comment.block.end</string>
21+
<key>excludeTrailingNewlines</key>
22+
<false/>
2123
</dict>
2224
<dict>
2325
<key>begin</key>
2426
<string>punctuation.definition.string.begin</string>
2527
<key>end</key>
2628
<string>punctuation.definition.string.end</string>
29+
<key>excludeTrailingNewlines</key>
30+
<false/>
31+
</dict>
32+
<dict>
33+
<key>begin</key>
34+
<string>punctuation.section.group.begin</string>
35+
<key>end</key>
36+
<string>punctuation.section.group.end</string>
37+
<key>excludeTrailingNewlines</key>
38+
<false/>
39+
</dict>
40+
<dict>
41+
<key>begin</key>
42+
<string>punctuation.section.braces.begin</string>
43+
<key>end</key>
44+
<string>punctuation.section.braces.end</string>
45+
<key>excludeTrailingNewlines</key>
46+
<false/>
2747
</dict>
2848
</array>
2949
</dict>

PowerShell.sublime-syntax

+14-12
Original file line numberDiff line numberDiff line change
@@ -811,15 +811,17 @@ contexts:
811811
- include: comment-line
812812

813813
regions:
814-
- match: ^(#region\s*(.*))$
815-
captures:
816-
# Applying the punctuation.section.block.begin scope to the entire pattern
817-
# allows Sublime Text to show the region name when it is folded.
818-
1: punctuation.section.block.begin.powershell comment.line.powershell
819-
2: meta.toc-list.powershell
820-
- match: ^#endregion\b
821-
scope: punctuation.section.block.end.powershell comment.line.powershell
822-
push:
823-
- meta_content_scope: comment.line.powershell
824-
- include: pop-at-newline
825-
- include: comment-embedded-docs
814+
- match: ^\s*(#)\s*(region)\b\s*(\S.*)
815+
captures:
816+
1: punctuation.definition.comment.powershell
817+
2: comment.line.powershell
818+
3: meta.toc-list.powershell meta.fold.begin.powershell entity.name.section.powershell
819+
- match: '^\s*(#)\s*(region)\b\s*'
820+
captures:
821+
1: punctuation.definition.comment.powershell
822+
2: comment.line.powershell meta.fold.begin.powershell
823+
- match: '^\s*(#)\s*(endregion\b[^\S\n]*.*)($\n?)'
824+
captures:
825+
1: punctuation.definition.comment.powershell
826+
2: comment.line.powershell
827+
3: meta.fold.end.powershell

Tests/syntax_test_PowerShell.ps1

+4-3
Original file line numberDiff line numberDiff line change
@@ -1812,9 +1812,10 @@ function get-number {}
18121812
#>
18131813

18141814
#region Test
1815-
#<- punctuation.section.block.begin comment.line
1816-
# ^^^^ meta.toc-list
1815+
#<- punctuation.definition.comment
1816+
#^^^^^^ comment.line.powershell
1817+
# ^^^^ meta.toc-list meta.fold.begin entity.name.section
18171818
# @@@@ local-definition
18181819
#endregion (Text after #endregion is optional, but the ISE marks it as a comment as well)
1819-
#<- punctuation.section.block.end comment.line
1820+
#<- punctuation.definition.comment.powershell
18201821
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line

0 commit comments

Comments
 (0)