Description
Environment data
- VS Code version: 1.27.2
- Extension version: 2018.9.0
- OS and version: macOS Sierra 10.12.6
- Python version: 3.7.0, installed via pyenv
- Type of virtual environment used: none
- Relevant/affected Python packages and their versions: none
Actual behavior
Sending a selected Python code for evaluation in the Python terminal via Run Selection/Line in Python Terminal results in "IndentationError: unexpected indent"
errors if the block of code is indented.
Example: evaluating the following selection results in an error because of the indentation of the whole block at 4 spaces:
Expected behavior
It would be useful if the evaluation of indented code worked regardless of it's position or level of indentation in the overall code (i.e. should be first deindented to a "base level" before sending to the terminal?).
As an example, the indented code above should be sent to the terminal as if it was the following (i.e. not indented):
I tend to work "bottom-up", evaluating/debugging smaller pieces of code that form more complex functions, and those individual pieces are obviously indented. This behavior makes this sort of workflow a little difficult.
Steps to reproduce
Use the following example code to test the behavior described above by evaluating the two commented blocks using Run Selection/Line in Python Terminal functionality.
def fn():
# block indented by 4 spaces -> results in an error
x, y = 10, 2
for i in range(x):
print(i ** y)
# block not indented -> correctly evaluated
x, y = 10, 2
for i in range(x):
print(i ** y)