You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Run Selection/Line in Python Terminal gives syntax errors when running selection with function def or other blocks #259
Hi Arundeep Singh (@arundeep78)! Thanks for letting us know about this issue. I've been able to reproduce the problem (at least under linux). It appears to be related to the blank lines getting dropped somewhere along the line. We'll look into it as soon as we can. Thanks again!
Miki Tebeka (@tebeka) we're hoping to release this week. If you want to help us validate that this got fixed, please install an insiders build and let us know if your issue was fixed.
Looks like blank lines within a block of code (if, while, for) needs to be stripped off or we should indent accordingly).
Each block of code should be separated with a blank line (i.e. different blocks of code should be separated with blank lines).
Sample 1
ifTrue:
print(1)
print(2)
In order to get the above working in the terminal, we should either strip the blank line between the two print statements or ensure the blank line is indented (i.e. has 4 spaces in this case).
Sample 2
ifTrue:
print(1)
print(2)
print(3)
For this code to work in the terminal, there must be a blank line between the last two print statements. I.e. we need a blank line to separate the if block from the rest of the code.
Either the leading newlines prepended to blank lines or stripping them are fine by me (I guess the blank prepending will lead to less surprise for people when looking at the REPL, but debugging that later will be a nightmare for any bug reports).
As for inserting the newline between blocks, we can't solve all problems at once. 😉
Activity
ericsnowcurrently commentedon Jan 18, 2018
Hi Arundeep Singh (@arundeep78)! Thanks for letting us know about this issue. I've been able to reproduce the problem (at least under linux). It appears to be related to the blank lines getting dropped somewhere along the line. We'll look into it as soon as we can. Thanks again!
tebeka commentedon Jan 23, 2018
I'm hitting this problem as well, would love to see it solved.
tebeka commentedon Jan 24, 2018
From what I can see
codeExectuoris callingnormalizeLineswhich removes empty lines.IMO we can drop the call to
normalizeLinesand it'll work. Any ideas?tebeka commentedon Jan 29, 2018
IMO this was fixed in ad806fa (by Don Jayamanne (@DonJayamanne)), is there a release planned soon?
brettcannon commentedon Jan 29, 2018
Miki Tebeka (@tebeka) we're hoping to release this week. If you want to help us validate that this got fixed, please install an insiders build and let us know if your issue was fixed.
tebeka commentedon Jan 29, 2018
I've linked the current source tree (at 36b3050) to
~/.vscode/extension/vscode-pythoand tried the code - it worked.If you prefer I'll check an exact versionn please LMK which one and I'll check.
brettcannon commentedon Jan 29, 2018
Nope, that does it! Thanks for the validation!
12 remaining items
DonJayamanne commentedon Apr 19, 2018
Brett Cannon (@brettcannon)
Looks like blank lines within a block of code (if, while, for) needs to be stripped off or we should indent accordingly).
Each block of code should be separated with a blank line (i.e. different blocks of code should be separated with blank lines).
Sample 1
In order to get the above working in the terminal, we should either strip the blank line between the two print statements or ensure the blank line is indented (i.e. has
4 spacesin this case).Sample 2
For this code to work in the terminal, there must be a blank line between the last two print statements. I.e. we need a blank line to separate the if block from the rest of the code.
More information here https://stackoverflow.com/questions/8391633/blank-line-rule-at-interactive-prompt
brettcannon commentedon Apr 19, 2018
Either the leading newlines prepended to blank lines or stripping them are fine by me (I guess the blank prepending will lead to less surprise for people when looking at the REPL, but debugging that later will be a nightmare for any bug reports).
As for inserting the newline between blocks, we can't solve all problems at once. 😉
Enhancements to running code in a terminal (#1432)
Remove news entry related to issue #259 as the issue was not fixed
Add blank lines to separate blocks of indented code (#1515)