Skip to content

Adding >1 new line within a codeblock doesn't correctly match the indentation #119356

Closed
@aelsayed95

Description

@aelsayed95

Bug report

Bug description:

Adding more than one new line within a codeblock doesn't correctly match the indentation the previous line's indentation:

For example if I start with the following codeblock:

>>> def f():
...     
...     a = 1
>>>

and modify it to add two additional new lines in-block, I end up with the following:

>>> def f():
...     
... 
... 
...     a = 1
...     
>>>

Note that now, lines 2,5 have indentation, but lines 3 and 4 have no indentation.
This doesn't match IPython's behaviour.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions