Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Python indentation too deep when expression before colon is multi-line #1182

@krassowski

Description

@krassowski

Describe the issue

When the expression in if, def or other block is spanning multiple lines the indent is too deep. It should be one level of indentation (for Python usually 4 spaces or tab) but it is as many spces as to match the position of the colon:

def test(x,
         y): # press enter here, see indent is too deep (fail!)

or

if (x
    and y): # press enter here, see indent is too deep (fail!)

This does not happen (i.e. works as expected) for single-line statments:

def test(x, y): # press enter here, see indent is one level deep (ok)

Browser and platform

Edge and Firefox

Reproduction link

https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge3B5dGhvbn0gZnJvbSAiQGNvZGVtaXJyb3IvbGFuZy1weXRob24iCgpuZXcgRWRpdG9yVmlldyh7CiAgZG9jOiAiZGVmIHRlc3QoeCxcbiAgICAgICAgIHkpOiAjIHByZXNzIGVudGVyIGhlcmUsIHNlZSBpbmRlbnQgdG9vIGRlZXAgKHNob3VsZCBiZSA0IHNwYWNlcyBidXQgaXMgMTEpXG4iLAogIGV4dGVuc2lvbnM6IFtiYXNpY1NldHVwLCBweXRob24oKV0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==

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