Skip to content

Auto-indent for Python spotty #11909

Closed
Closed

Description

  • VSCode Version: 1.5.2
  • OS Version: Windows 8.1 and Ubuntu Linux 16.04

When writing certain Python code, auto-indent/de-indent fails to properly indent/de-indent lines as expected. For example, if I write:

if myVar == 1:
    print("This is equal to 1")
else:
    print ("This is not equal to 1")

The editor fails to automatically indent the "else" statement. it should be able to detect that I am entering an "else" statement and properly handle indentation and de-indentation. The same issue occurs on try/except blocks.

try:
    subprocess.check_output("someprogram.exe")
except CalledProcessException:
    print("The process failed.")

The editor should be able to detect when it sees the except block starter and properly de--indent the code as expected. As it stands, both the if/else and try/except blocks look like this when entered into the editor:

if myvar == 1:
    print("This is equal to 1")
    else:
        print("This is not equal to 1")

Activity

  1. sumit0190 commented on Sep 13, 2016

    @sumit0190

    I think #2272 addresses the bigger problem that's causing indentation issues across all languages. Solving that should automatically take care of such issues. I could be wrong though.

  2. bpasero commented on Sep 13, 2016

    @bpasero
    Contributor

    This should be reported to the Python repository first.

  3. locked and limited conversation to collaborators on Nov 18, 2017
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions