Skip to content

Python language parser does not properly indent else clause in for and while loops #1363

@sergeichestakov

Description

@sergeichestakov

Describe the issue

It seems the Python parser does not correctly handle for/else loops and while/else loops, particularly with respect to indentation in nested blocks.

Admittedly, I myself only just found this out but turns out an else clause in a while or for loop is valid Python code (see docs and examples) so I believe the Python parser should handle it appropriately and indent else clauses the same as it does with a matching if statement.

See repro gif below to showcase what I mean:

python-for-while-indentation-bug

Browser and platform

latest MacOS, Firefox (but should repro in all)

Reproduction link

https://replit.com/@SergeiChestakov/cm-py-indentation-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions