Skip to content

Commit 040d175

Browse files
committed
Sync region scopes to upstream C#
Fixes #221
1 parent 0e1921d commit 040d175

4 files changed

Lines changed: 53 additions & 44 deletions

File tree

PowerShell.sublime-syntax

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,19 +1297,17 @@ contexts:
12971297
2: punctuation.definition.label.powershell
12981298

12991299
regions:
1300-
- match: ^\s*((#)\s*(region\b)(?:\s*(\S.*))?(\n?))
1301-
captures:
1302-
1: comment.line.powershell
1303-
2: punctuation.definition.comment.powershell
1304-
3: keyword.other.region.begin.powershell
1305-
4: meta.toc-list.powershell entity.name.section.powershell
1306-
5: meta.fold.begin.powershell
1307-
- match: ^\s*((#)\s*(endregion\b).*(\n?))
1308-
captures:
1309-
1: comment.line.powershell
1310-
2: punctuation.definition.comment.powershell
1311-
3: keyword.other.region.end.powershell
1312-
4: meta.fold.end.powershell
1300+
- match: ^\s*(#)\s*(region\b)(?:\s*(\S.*))?(\s*\n?)
1301+
captures:
1302+
1: punctuation.definition.preprocessor.powershell
1303+
2: keyword.control.directive.region.powershell
1304+
3: entity.name.section.powershell
1305+
4: meta.fold.block.begin.powershell
1306+
- match: ^\s*(#)\s*(endregion\b)(?:\s*(\S.*))?\s*\n?
1307+
captures:
1308+
1: meta.fold.block.end.powershell punctuation.definition.preprocessor.powershell
1309+
2: keyword.control.directive.endregion.powershell
1310+
3: variable.other.section.powershell
13131311

13141312
###[ COMMENTS ]################################################################
13151313

support/Fold.tmPreferences

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<array>
1010
<dict>
1111
<key>begin</key>
12-
<string>meta.fold.begin</string>
12+
<string>meta.fold.block.begin</string>
1313
<key>end</key>
14-
<string>meta.fold.end</string>
14+
<string>meta.fold.block.end</string>
1515
</dict>
1616
<dict>
1717
<key>begin</key>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<plist version="1.0">
3+
<dict>
4+
<key>scope</key>
5+
<string>source.powershell entity.name.section</string>
6+
<key>settings</key>
7+
<dict>
8+
<key>showInSymbolList</key>
9+
<integer>1</integer>
10+
<key>symbolTransformation</key>
11+
<string>
12+
s/\s{2,}/ /g; # collapse whitespace
13+
s/^/#region /;# prepend "#region " to the region name
14+
</string>
15+
</dict>
16+
</dict>
17+
</plist>

tests/syntax_test_PowerShell.ps1

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,30 +2364,26 @@ $a3[1..2]
23642364
#>
23652365

23662366
#region Test
2367-
#<- punctuation.definition.comment
2368-
#^^^^^^ keyword.other.region.begin
2369-
#<- comment.line.powershell
2370-
# ^^^^ meta.toc-list entity.name.section
2371-
# @@@@ local-definition
2372-
# ^ meta.fold.begin
2367+
#<- punctuation.definition.preprocessor
2368+
#^^^^^^ keyword.control.directive.region
2369+
# ^^^^ entity.name.section
2370+
# @@@@ local-definition "#region Test"
2371+
# ^ meta.fold.block.begin
23732372
Do-Stuff
23742373
# @@@@@@@@ reference
23752374
#endregion (More comments)
2376-
#<- punctuation.definition.comment.powershell
2377-
#^^^^^^^^^ keyword.other.region.end.powershell
2378-
#<- comment.line
2379-
# ^ meta.fold.end
2375+
#<- meta.fold.block.end punctuation.definition.preprocessor
2376+
#^^^^^^^^^ keyword.control.directive.endregion
2377+
# ^^^^^^^^^^^^^^^ variable.other.section.powershell
23802378

23812379
#region
2382-
#<- punctuation.definition.comment
2383-
#^^^^^^ keyword.other.region.begin
2384-
#<- comment.line.powershell
2385-
# ^ meta.fold.begin
2380+
#<- punctuation.definition.preprocessor
2381+
#^^^^^^ keyword.control.directive.region
2382+
# ^ meta.fold.block.begin
23862383
#endregion (More comments)
2387-
#<- punctuation.definition.comment.powershell
2388-
#^^^^^^^^^ keyword.other.region.end.powershell
2389-
#<- comment.line
2390-
# ^ meta.fold.end
2384+
#<- meta.fold.block.end punctuation.definition.preprocessor
2385+
#^^^^^^^^^ keyword.control.directive.endregion
2386+
# ^^^^^^^^^^^^^^^ variable.other.section.powershell
23912387

23922388
function Process-DeploymentConfig {
23932389
# @@@@@@@@@@@@@@@@@@@@@@@@ definition
@@ -2401,12 +2397,11 @@ function Process-DeploymentConfig {
24012397
)
24022398

24032399
#region PathHelper
2404-
# ^^^^^^^^^^^^^^^^^^^ comment.line.powershell
2405-
# ^ punctuation.definition.comment
2406-
# ^^^^^^ keyword.other.region.begin
2407-
# ^^^^^^^^^^ meta.toc-list entity.name.section
2408-
# @@@@@@@@@@ local-definition
2409-
# ^ meta.fold.begin
2400+
# ^ punctuation.definition.preprocessor
2401+
# ^^^^^^ keyword.control.directive.region
2402+
# ^^^^^^^^^^ entity.name.section
2403+
# @@@@@@@@@@ local-definition "#region PathHelper"
2404+
# ^ meta.fold.block.begin
24102405

24112406
function Resolve-ConfigPath {
24122407
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.function.powershell
@@ -2430,11 +2425,10 @@ function Process-DeploymentConfig {
24302425
}
24312426
return $ResolvedPath
24322427
}
2433-
#endregion
2434-
# ^^^^^^^^^^^ comment.line.powershell
2435-
# ^ punctuation.definition.comment.powershell
2436-
# ^^^^^^^^^ keyword.other.region.end.powershell
2437-
# ^ meta.fold.end
2428+
#endregion PathHelper
2429+
# ^ meta.fold.block.end punctuation.definition.preprocessor
2430+
# ^^^^^^ keyword.control.directive.endregion
2431+
# ^^^^^^^^^^ variable.other.section.powershell
24382432

24392433

24402434
Resolve-ConfigPath -Path "Foo" -PathVariables $PathVariables

0 commit comments

Comments
 (0)