-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Run selection indentation error #14048
Comments
I incorrectly listed my Python extension version, I was on v2020.9.106471-dev, reverting to v2020.8.109390 hasn't resolved the issue however. |
I can replicate the issue with: if a:
b
elif c:
d
else:
e |
I've tried this using different extension versions and can reproduce it on: 2020.8.108011 |
I just noticed 2020.9.111407 dropped, I can reproduce this on this version as well. |
Perhaps this hasn't been working for a long time and I just haven't encountered it, I'm noticing that these two scenarios work.
|
I have noticed that I'm not able to repro this all on all Python versions. For eg. it works with Python 3.7.1-64 bit. Investigating further... |
Spike resultsWe insert blank lines between global statements, for eg. the following selection has two global statements: the if-else block and print. if True:
print('true')
else:
print('')
print('') So we insert an extra character between the two, hence it's run as two different statements The bug is that starting from somewhere around Python 3.7.5, the following if a:
b
elif c:
d is being considered as two global statements and so sent separately, if a:
b & elif c:
d so sending the second elif block fails. The vscode-python/pythonFiles/normalizeForInterpreter.py Lines 48 to 57 in a58eeff
We can either modify the logic or how we use |
Nice. It helps a lot. |
This should be fixed on our newest release, version 2021.1.502429796, but if you're still seeing this let us now 😊 |
Environment data
Version: 1.49.1
Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf
Date: 2020-09-16T23:21:17.533Z (6 days ago)
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0
2020.8.1 (20 August 2020)
Python 3.7.8, Python 3.8.4
venv, and without a virtual environment
N/A
N/A
python.languageServer
setting:Pylance
[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (
python.languageServer: 'Microsoft'
), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]Expected behaviour
When I highlight Python code and run selection I expect it to run if it is syntactically correct.
Actual behaviour
I'm receiving indentation errors in specific scenarios for code that is syntactically correct.
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
Run selection on the following code and the following error(s) will occur
If I copy/paste the same code into the Python interactive window it will run without error.
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)The text was updated successfully, but these errors were encountered: