Skip to content

Commit e98fe9c

Browse files
authored
[Python] Unify block begin punctuation (#4413)
This commit scopes all colons `punctuation.section.block.begin`, which start an indented block of code, regardless their actual context. The point is colon indicating a start of a code block, like an opening brace in a C-style language. We just don't scope the block `meta.block` as we don't want or can't reliably count indentation to pop it off, correctly.
1 parent 88c0344 commit e98fe9c

File tree

2 files changed

+78
-78
lines changed

2 files changed

+78
-78
lines changed

Python/Python.sublime-syntax

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ contexts:
853853
class-definition-end:
854854
- meta_content_scope: meta.class.python
855855
- match: '{{colon}}'
856-
scope: meta.class.python punctuation.section.class.begin.python
856+
scope: meta.class.python punctuation.section.block.begin.python
857857
pop: 1
858858
- include: line-continuation-or-pop
859859

@@ -1053,7 +1053,7 @@ contexts:
10531053
- match: (\s*)({{colon}})
10541054
captures:
10551055
1: meta.function.return-type.python
1056-
2: meta.function.python punctuation.section.function.begin.python
1056+
2: meta.function.python punctuation.section.block.begin.python
10571057
pop: 1
10581058
- include: line-continuation-or-pop
10591059
- include: function-return-type-content
@@ -1066,7 +1066,7 @@ contexts:
10661066

10671067
function-definition-end:
10681068
- match: '{{colon}}'
1069-
scope: meta.function.python punctuation.section.function.begin.python
1069+
scope: meta.function.python punctuation.section.block.begin.python
10701070
pop: 1
10711071
- include: line-continuation-or-pop
10721072
- include: illegal-assignment-expressions
@@ -1258,7 +1258,7 @@ contexts:
12581258
- match: '{{colon}}'
12591259
scope:
12601260
meta.statement.conditional.case.python
1261-
punctuation.section.block.conditional.case.python
1261+
punctuation.section.block.begin.python
12621262
pop: 1
12631263

12641264
case-statement-fail:
@@ -1493,20 +1493,20 @@ contexts:
14931493
scope: meta.statement.conditional.else.python
14941494
captures:
14951495
1: keyword.control.conditional.else.python
1496-
2: punctuation.section.block.conditional.else.python
1496+
2: punctuation.section.block.begin.python
14971497

14981498
if-statement-condition:
14991499
- meta_scope: meta.statement.conditional.if.python
15001500
- match: '{{colon}}'
1501-
scope: punctuation.section.block.conditional.if.python
1501+
scope: punctuation.section.block.begin.python
15021502
pop: 1
15031503
- include: line-continuation-or-pop
15041504
- include: expression-in-a-statement
15051505

15061506
elif-statement-condition:
15071507
- meta_scope: meta.statement.conditional.elseif.python
15081508
- match: '{{colon}}'
1509-
scope: punctuation.section.block.conditional.elseif.python
1509+
scope: punctuation.section.block.begin.python
15101510
pop: 1
15111511
- include: line-continuation-or-pop
15121512
- include: expression-in-a-statement
@@ -1531,7 +1531,7 @@ contexts:
15311531
except-statement-exception-list:
15321532
- meta_scope: meta.statement.exception.catch.python
15331533
- match: '{{colon}}'
1534-
scope: punctuation.section.block.exception.catch.python
1534+
scope: punctuation.section.block.begin.python
15351535
pop: 1
15361536
- match: as\b
15371537
scope: keyword.control.exception.catch.as.python
@@ -1543,7 +1543,7 @@ contexts:
15431543
except-statement-as:
15441544
- meta_content_scope: meta.statement.exception.catch.python
15451545
- match: '{{colon}}'
1546-
scope: meta.statement.exception.catch.python punctuation.section.block.exception.catch.python
1546+
scope: meta.statement.exception.catch.python punctuation.section.block.begin.python
15471547
pop: 1
15481548
- include: illegal-assignment-expressions
15491549
- include: line-continuation-or-pop
@@ -1572,7 +1572,7 @@ contexts:
15721572
for-statement-in:
15731573
- meta_content_scope: meta.statement.loop.for.python
15741574
- match: '{{colon}}'
1575-
scope: meta.statement.loop.for.python punctuation.section.block.loop.for.python
1575+
scope: meta.statement.loop.for.python punctuation.section.block.begin.python
15761576
pop: 1
15771577
- include: line-continuation-or-pop
15781578
- include: expression-in-a-statement
@@ -1610,7 +1610,7 @@ contexts:
16101610

16111611
match-statement-end:
16121612
- match: '{{colon}}'
1613-
scope: punctuation.section.block.conditional.match.python
1613+
scope: punctuation.section.block.begin.python
16141614
set: maybe-first-case-statement
16151615

16161616
maybe-first-case-statement:
@@ -1671,7 +1671,7 @@ contexts:
16711671
while-statement-condition:
16721672
- meta_scope: meta.statement.loop.while.python
16731673
- match: '{{colon}}'
1674-
scope: punctuation.section.block.loop.while.python
1674+
scope: punctuation.section.block.begin.python
16751675
pop: 1
16761676
- include: line-continuation-or-pop
16771677
- include: expression-in-a-statement
@@ -1691,7 +1691,7 @@ contexts:
16911691
with-statement-plain:
16921692
- meta_scope: meta.statement.with.python
16931693
- match: '{{colon}}'
1694-
scope: punctuation.section.block.with.python
1694+
scope: punctuation.section.block.begin.python
16951695
pop: 1
16961696
- match: as\b
16971697
scope: keyword.control.flow.with.as.python
@@ -1735,7 +1735,7 @@ contexts:
17351735
with-statement-tuple-end:
17361736
- meta_content_scope: meta.statement.with.python
17371737
- match: '{{colon}}'
1738-
scope: meta.statement.with.python punctuation.section.block.with.python
1738+
scope: meta.statement.with.python punctuation.section.block.begin.python
17391739
pop: 1
17401740
- include: with-statement-tuple-else-fail
17411741

@@ -1907,7 +1907,7 @@ contexts:
19071907
lambda-in-group-parameters:
19081908
- meta_content_scope: meta.function.inline.parameters.python
19091909
- match: '{{colon}}'
1910-
scope: meta.function.inline.python punctuation.section.function.begin.python
1910+
scope: meta.function.inline.python punctuation.section.block.begin.python
19111911
set:
19121912
- meta_include_prototype: false
19131913
- match: ''
@@ -1937,7 +1937,7 @@ contexts:
19371937
lambda-parameters:
19381938
- meta_content_scope: meta.function.inline.parameters.python
19391939
- match: '{{colon}}'
1940-
scope: meta.function.inline.python punctuation.section.function.begin.python
1940+
scope: meta.function.inline.python punctuation.section.block.begin.python
19411941
set:
19421942
- meta_include_prototype: false
19431943
- match: ''

0 commit comments

Comments
 (0)