Skip to content

Indentation level of else:-type lines is not reduced #771

Closed

Description

@nathdwek

Environment data

VS Code version:

1.20.0
c63189deaa8e620f650cc28792b8f5f3363f2c5b
x64

Python Extension version: 2018.1.0
Python Version: 3.6.3
OS and version: Ubuntu 2017.10 AMD64

Actual behavior

After typing enter at the end of a line such as else:, elif cond:, except:, finally:, the indentation level of that line is unchanged and the next line is auto-indented to the wrong level as well:

if cond:
    do_stuff()
    else:|

after typing enter, becomes

if cond:
    do_stuff()
    else:
        |

Expected behavior

if cond:
    do_stuff()
    else:|

after typing enter (or : on atom if I remember correctly), should become

if cond:
    do_stuff()
else:
    |

Steps to reproduce:

  • Use a construct as if-elif-else, try-except-else-finally.

Is this normal? I expect that this is a problem with my setup and not this extension given the simplicity of the issue, but my install is as standard as can be...

Activity

  1. MikhailArkhipov commented on Feb 20, 2018

    @MikhailArkhipov

    The caret is placed correctly, one level less than else:. Moving else requires AST/autoformatting infrastructure.

  2. nathdwek commented on Feb 21, 2018

    @nathdwek
    Author

    OK, good to know this is currently expected behaviour.
    Thank you for trying to tackle this!

  3. AlexChapple commented on Jul 8, 2018

    @AlexChapple

    Is there an update on this?

  4. brettcannon commented on Jul 11, 2018

    @brettcannon
    Member

    [ @redoctopus0 I edited your ✉️ ⬆️ to come off as more 😃 and less 😠 ]

    Fixing this requires #1847 which is not a minor undertaking. So we expect to get to it eventually, but it might be a little while.

  5. brettcannon commented on Oct 17, 2018

    @brettcannon
    Member

    Was supposed to be fixed by #2724 .

  6. added
    bugIssue identified by VS Code Team member as probable bug
    and removed
    feature-requestRequest for new features or functionality
    on Oct 17, 2018
  7. locked as resolved and limited conversation to collaborators on Nov 14, 2018
  8. luabud commented on Mar 15, 2019

    @luabud
    Member

    tracked by #481

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

    area-formattingbugIssue identified by VS Code Team member as probable bugwindows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions