Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto indent else inside if block #16105

Closed
thistlillo opened this issue May 1, 2021 · 3 comments
Closed

Auto indent else inside if block #16105

thistlillo opened this issue May 1, 2021 · 3 comments
Labels
area-editor-* User-facing catch-all bug Issue identified by VS Code Team member as probable bug regression Bug didn't exist in a previous release

Comments

@thistlillo
Copy link

I would like to report exactly the same issue in https://github.com/microsoft/vscode-python/issues/2147.
I am working remotely via remote-ssh on a Linux machine from my Windows 10 laptop.
The Python extension for Visual Studio Code has been installed remotely (and locally).

Basically, just by hitting enter at the end of each line, I get:

def a():
    x = 1 
    if x==1:
        print(1)
        else:
            print(2) 

when I should get (that is what I actually want);

def a():
    x = 1 
    if x==1:
        print(1)
    else:
        print(2)

Version: 1.55.2 (user setup)
Commit: 3c4e3df9e89829dce27b7b5c24508306b151f30d
Date: 2021-04-13T09:35:57.887Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19042

Environment data

  • VS Code version: 1.55.2
  • Extension version (available under the Extensions sidebar): Python extension for Visual Studio Code v2021.4.765268190
  • OS and version: Windows 10 Pro, Windows Feature Experience Pack 120.2212.551.0
    ** but working remotely on Ubuntu 16.04.7 LTS **
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.10, [GCC 5.4.0 20160609] on linux
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Value of the python.languageServer setting: "Pylance"

Expected behaviour

Correct indentation

Actual behaviour

Wrong indent.

Steps to reproduce:

Just type the code above.

@thistlillo thistlillo added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels May 1, 2021
@karthiknadig karthiknadig added area-editor-* User-facing catch-all triage and removed triage-needed Needs assignment to the proper sub-team labels May 3, 2021
@karrtikr karrtikr changed the title Wrong indent, as in the past. Auto indent else inside if block May 3, 2021
@karrtikr
Copy link

karrtikr commented May 3, 2021

Thanks for the bug report, I can confirm the issue. This was introduced when we removed the on enter format when editor.formatOnType setting is enabled. We plan to fix all these issues as part of #8996.

Meanwhile, can you try installing the Python Indent extension and see if it helps?

@karrtikr karrtikr removed their assignment May 3, 2021
@karrtikr karrtikr added needs PR regression Bug didn't exist in a previous release and removed triage labels May 3, 2021
@thistlillo
Copy link
Author

Meanwhile, can you try installing the Python Indent extension and see if it helps?

After installing that extension, the automatic indentation (in the case above) is correct. Thank you.

@luabud
Copy link
Member

luabud commented May 5, 2021

Closing in favour of #8996

@luabud luabud closed this as completed May 5, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-editor-* User-facing catch-all bug Issue identified by VS Code Team member as probable bug regression Bug didn't exist in a previous release
Projects
None yet
Development

No branches or pull requests

4 participants