Skip to content

Auto indentation broken when return keyword involved #141

@DonJayamanne

Description

@DonJayamanne

From @jarshwah on July 17, 2017 2:56

Environment data

VS Code version: 1.14.0
Python Extension version: 0.6.7
Python Version: 2.7.13
OS and version: OSX 10.12.5 (16F73)

Actual behavior

Auto indentation of function arguments fails when the function is preceded by the return keyword. The closing paren is put on the first column along with the cursor. Removing the return keyword fixes the issue.

# | represents cursor

def failing():
    return arg(|)  # hit enter

def failing():
    return arg(
|)

def works():
    arg(|)  # hit enter

def works():
    arg(
        |
    )

Expected behavior

def failing():
    return arg(|)  # hit enter

def failing():
    return arg(
        |
    )

Steps to reproduce:

See expected and actual behaviour above

Settings

Your settings.json:

// Place your settings in this file to overwrite the default settings
{
  "extensions.autoUpdate": true,
  "editor.autoIndent": true,
  "editor.fontSize": 13,
  "editor.fontFamily": "Source Code Pro",
  "editor.minimap.enabled": false,
  "editor.wordWrap": "off",
  "editor.rulers": [
  79, 99, 119
],
"editor.renderIndentGuides": true,
"editor.renderLineHighlight": "all",
"editor.dragAndDrop": false,
"emmet.useNewEmmet": true,
  "files.insertFinalNewline": true,
  "python.pythonPath": "python3",
  "python.formatting.provider": "yapf",
  "python.formatting.autopep8Args": ["--max-line-length=119"],
  "python.linting.pylintEnabled": false,
  "python.linting.flake8Args": ["--max-line-length=119"],
  "python.linting.enabled": true,
  "python.linting.pep8Enabled": false,
  "python.linting.flake8Enabled": true,
  "python.workspaceSymbols.exclusionPatterns": [
    "**/site-packages/**",
    ".tox/**"
  ],
  "workbench.editor.showTabs": true,
  "editor.renderWhitespace": "all",
  "files.trimTrailingWhitespace": true,
  "window.zoomLevel": 0,
  "vsicons.projectDetection.autoReload": true,
  "workbench.colorTheme": "Atom One Dark",
  "workbench.iconTheme": "vscode-icons",
  "workbench.editor.enablePreview": true,
  "workbench.editor.revealIfOpen": true,
  "sync.host": "",
  "sync.pathPrefix": "",
  "typescript.tsserver.log": "verbose",
  "search.useRipgrep": false // todo: remove once global search fixed
}

Logs

Output from Python output panel

No Relevant Logs

Output from Console window (Help->Developer Tools menu)

No Relevant Logs

I see the same behaviour by switching the "editor.autoIndent": true, to false. Only began happening with 1.14.0 from memory.

Copied from original issue: DonJayamanne/pythonVSCode#1087

Metadata

Metadata

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions