Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Incorrect indentation when closing hanging indent #12

Description

@kbrose

If a hanging indent is closed after some values have been entered, it incorrectly keeps the indentation level.

Example:

x = [
    0,1,2,3]

pressing enter before the ] character results in

x = [
    0,1,2,3
    ]

instead of producing

x = [
    0,1,2,3
]

as expected. If the hanging indent were created to begin with, then the bracket would be correctly placed, this only occurs if a previously non-hanging-indented set of lines were converted to a hanging indent.

Note, however, that it is not enough simply to look for a comma. Consider the case of the (admittedly rarely used) multi-line string created via parentheses:

x = (
    'here is a multi-line string'
    ' that spans several lines without any commas'
    ' how will we detect this correctly? If this were'
    ' inside brackets, then we would want to see if there'
    ' is a comma, but since it is parentheses, there does'
    ' not need to be a comma...'
    'It appears as if there is no certain way to tell what the'
    ' indentation should be here, probably best to default to'
    ' current behavior, which is to set indentation to current indentation.'
)

x = [
    'compare the above to this',
    'where now we should close the hanging'
    'indent because there is no comma'
]

Need to think more about what the desired behavior actually is here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions