Skip to content

Commit

Permalink
[Python] Scope self and cls in function parameter lists (#4059)
Browse files Browse the repository at this point in the history
This commit scopes `cls` and `self` special in parameter lists,
to enable highlighting them as their references in function bodies.
  • Loading branch information
deathaxe authored Oct 19, 2024
1 parent f0e173b commit f2a1644
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Python/Python.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -2408,6 +2408,8 @@ contexts:

parameter-names:
- include: illegal-names
- match: (?:self|cls)\b
scope: variable.parameter.python variable.language.python
- match: '{{identifier}}'
scope: variable.parameter.python

Expand Down
3 changes: 3 additions & 0 deletions Python/tests/syntax_test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2124,6 +2124,9 @@ class MyClass():
# ^^ meta.class.inheritance.python - meta.class meta.class
# ^ meta.class.python - meta.class meta.class punctuation.section.class.begin
def my_func(self, param1, # Multi-line function definition
# ^^^^ variable.parameter.python variable.language.python
# ^ punctuation.separator.parameters.python
# ^^^^^^ variable.parameter.python - variable.language
# ^ comment.line.number-sign
# This is defaulted
# ^ comment.line.number-sign
Expand Down

0 comments on commit f2a1644

Please sign in to comment.