vscode: wrong indentation detection for python

Issue Type: Bug

open a file including these line:

def foo(bars):
    for bar in bars:
        pass

vs code will detect the indentation as Spaces: 8, where the correct indentation setting should be 4 spaces.

VS Code version: Code 1.28.2 (7f3ce96ff4729c91352ae6def877e59c561f4850, 2018-10-17T00:20:56.183Z) OS version: Linux x64 4.15.0-38-lowlatency

Extensions (13)
Extension Author (truncated) Version
code-gnu-global aus 0.2.2
thrift cdu 0.0.1
vscode-markdownlint Dav 0.21.0
code-runner for 0.9.5
latex-workshop Jam 5.13.0
racket kar 0.0.3
vscode-clang mit 0.2.3
anaconda-extension-pack ms- 1.0.1
python ms- 2018.9.2
cpptools ms- 0.20.1
vscode-yaml red 0.0.17
cmake twx 0.0.17
clang-format xav 1.6.2

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 15 (2 by maintainers)

Most upvoted comments

This does not trigger the bug, it is detected as 4 spaces:

class Foo:
    def bar(self):
        pass

This does trigger the bug and is detected as 8 spaces:

def foo():
    for i in range(3):
        print(i)

All extensions are disabled.

It is the parenthesis on the first line that makes the difference! If I remove the () from the “def foo():” then without changing anything else it would correctly detect it as 4 spaces!

Close in favor of https://github.com/microsoft/vscode/issues/62143, which is fixed in master already.

please fix this problem, it’s really annoying… 😦