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

wrong indentation detection for python #62464

Closed
beantowel opened this issue Nov 2, 2018 · 15 comments
Closed

wrong indentation detection for python #62464

beantowel opened this issue Nov 2, 2018 · 15 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) editor-autoindent Editor auto indentation issues

Comments

@beantowel
Copy link

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 (7f3ce96, 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
@vscodebot
Copy link

vscodebot bot commented Nov 2, 2018

@vscodebot vscodebot bot added the editor-autoindent Editor auto indentation issues label Nov 2, 2018
@kieferrm
Copy link
Member

kieferrm commented Nov 2, 2018

The auto indentation rules come from the Python extension. Please file the issue there: https://github.com/Microsoft/vscode-python/issues. Thanks!

@kieferrm kieferrm added the *caused-by-extension Issue identified to be caused by an extension label Nov 2, 2018
@vscodebot
Copy link

vscodebot bot commented Nov 2, 2018

This issue is caused by an extension, please file it with the repository (or contact) the extension has linked in its overview in VS Code or the marketplace for VS Code. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Nov 2, 2018
@beantowel
Copy link
Author

The auto indentation rules come from the Python extension. Please file the issue there: https://github.com/Microsoft/vscode-python/issues. Thanks!

i've tried disable all the extensions and reload the window, the problem still there.

@ccaspers
Copy link

ccaspers commented Nov 3, 2018

The auto indentation rules come from the Python extension. Please file the issue there: https://github.com/Microsoft/vscode-python/issues. Thanks!

i've tried disable all the extensions and reload the window, the problem still there.

Same here. The detected indentation is wrong, regardless of the python extension being enabled or not.

@noinkling
Copy link

noinkling commented Dec 14, 2018

I'm encountering a very similar (probably the same) issue in markdown: #65043

@teodorlu
Copy link

teodorlu commented Mar 18, 2019

I'm also encountering this issue.

  • VS Code deduces 8 spaces per indentation for source files with 4 spaces per indentation
  • I do not have the vscode-python extension installed
  • code -version: 1.32.3 a3db5be x64
import contextlib


@contextlib.contextmanager
def readonly_odb(odbpath):
    import odbAccess
    odb = odbAccess.openOdb(path=odbpath, readOnly=True)
    try:
        yield odb
    finally:
        odb.close()


def testodb(odbpath):
    import odbAccess
    with readonly_odb(odbpath) as odb:
        pass


def main():
    testodb(r"C:\temp\smalloutput\BF-K11_004-p03_d90_2019-03-10.odb")
    pass

@prof7bit
Copy link

prof7bit commented Apr 4, 2019

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!

@lucasgcb
Copy link

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!

Can confirm. All my pytest files are quite annoying to deal with because of this.

@JackLiar
Copy link

please fix this problem, it's really annoying...... :(

@JackLiar
Copy link

on macOS 10.14.4/Ubuntu 17.04, vscode 1.33.1

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

is wrong too

@head-wired
Copy link

I have the same problem (Win 10 1809) vscode 1.33.1
automatic indentation is always a multiple of 8 (instead of 4) when pressing enter and going to a new line that requires an indentation change.

I'm pretty sure this worked correctly in the past.

@nuumio
Copy link

nuumio commented May 24, 2019

Just ran into this with 1.34.0 on Ubuntu 18.04.2. Quite annoying especially in Python. I disabled all extensions and it still happens.

Version: 1.34.0
Commit: a622c65
Date: 2019-05-15T21:55:35.507Z
Electron: 3.1.8
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Linux x64 4.15.0-50-generic

To reproduce create foo.py and write (with indent of 4 spaces):

def foo():
    if True:
        pass

Save, close and re-open foo.py. Add function bar() and indent is 8 spaces.

def foo():
    if True:
        pass

def bar():
        if True:
                pass

Workaround: Disable Editor: Detect Indentation.

@JAAdrian
Copy link

JAAdrian commented Jul 8, 2019

Just ran into this with 1.34.0 on Ubuntu 18.04.2. Quite annoying especially in Python. I disabled all extensions and it still happens.

Version: 1.34.0
Commit: a622c65
Date: 2019-05-15T21:55:35.507Z
Electron: 3.1.8
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Linux x64 4.15.0-50-generic

To reproduce create foo.py and write (with indent of 4 spaces):

def foo():
    if True:
        pass

Save, close and re-open foo.py. Add function bar() and indent is 8 spaces.

def foo():
    if True:
        pass

def bar():
        if True:
                pass

Workaround: Disable Editor: Detect Indentation.

I can confirm the same behavior on my side.

Version: 1.36.0
OS: Linux Mint 19 x64 5.0.0-20-generic

@rebornix rebornix added the bug Issue identified by VS Code Team member as probable bug label Aug 2, 2019
@rebornix
Copy link
Member

rebornix commented Aug 5, 2019

Close in favor of #62143, which is fixed in master already.

@rebornix rebornix closed this as completed Aug 5, 2019
@rebornix rebornix added the *duplicate Issue identified as a duplicate of another issue(s) label Aug 5, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) editor-autoindent Editor auto indentation issues
Projects
None yet
Development

No branches or pull requests