question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto indentation broken when return keyword involved

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
DonJayamannecommented, Dec 20, 2017

I’m sorry for not getting back to you any sooner. I can confirm this is a bug in the extension.

Read more comments on GitHub >

github_iconTop Results From Across the Web

emacs 24 c++ auto-indentation broken - Stack Overflow
Periodically after a while coding, my indentation engine seems to break -- pressing "tab" to indent places places any line at the beginning...
Read more >
Indenting C Programs
Two Common Compound Statement Indentation Styles ... What about programs that will automatically indent source code for you? Such "crutches" do exist, ...
Read more >
Indent - Neovim docs
Vim has options for automatically indenting C style program files. ... 'cinwords' Defines keywords that start an extra indent in the next line....
Read more >
indent: Indent and Format C Program Source - GNU.org
When a statement is broken across two lines, the second line is indented by a number of additional spaces specified by the -ci...
Read more >
How to Indent and Dedent Your Python Code - Dummies.com
You're going to have to change the number of spaces in front of one or more lines of code. It's common in programming...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found