Skip to content

Comments

[Python] Fix broken highlighting after case statements#4436

Merged
deathaxe merged 5 commits intosublimehq:masterfrom
deathaxe:pr/python/fix-defs-after-case
Feb 6, 2026
Merged

[Python] Fix broken highlighting after case statements#4436
deathaxe merged 5 commits intosublimehq:masterfrom
deathaxe:pr/python/fix-defs-after-case

Conversation

@deathaxe
Copy link
Collaborator

@deathaxe deathaxe commented Feb 4, 2026

Fixes #4433

This PR fixes various highlighting issues after first case statement, caused by meta.disable-dedentation pattern requirements.

It removes ^\s* restrictions from various patterns.

This commit removes `^\s*` restriction from function definitions' patterns
to ensure those are matched after first case statements.

Leading whitespace of a line after first case statement is already consumed
and scoped `meta.disable-dedentation` to support ST's indentation engine.

For consistency the restriction is globally removed, so space before `def`
keyword is never scoped `meta.function`.
This commit removes `^\s*` restriction from class definitions' patterns
to ensure those are matched after first case statements.

Leading whitespace of a line after first case statement is already consumed
and scoped `meta.disable-dedentation` to support ST's indentation engine.

For consistency the restriction is globally removed, so space before `class`
keyword is never scoped `meta.class`.
This commit removes `^\s*` restriction from type definitions' patterns
to ensure those are matched after first case statements.

Leading whitespace of a line after first case statement is already consumed
and scoped `meta.disable-dedentation` to support ST's indentation engine.

For consistency the restriction is globally removed, so space before `type`
keyword is never scoped `meta.type-alias`.
This commit pushes a special context for special patterns right after first
case statement in order to consume decorators.

A `@` denotes an decorator only at the beginning of a line.
In any other position it is an operator.
@deathaxe deathaxe merged commit 7b3be8b into sublimehq:master Feb 6, 2026
2 checks passed
@deathaxe deathaxe deleted the pr/python/fix-defs-after-case branch February 6, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Valid "def/class" as invalid in match-case.

3 participants