Auto indentation broken when return keyword involved
See original GitHub issueFrom @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:
- Created 6 years ago
- Comments:7
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m sorry for not getting back to you any sooner. I can confirm this is a bug in the extension.
https://github.com/Microsoft/vscode-python/commit/fb99423a3291fbd11fd2c4bae56bf8a8b855d07f