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
python chunks with empty lines aren't run #11665
Comments
We have a bunch of code that tries to pre-process console input here, to fix up indents: rstudio/src/cpp/session/SessionConsoleInput.cpp Lines 161 to 288 in 78304db
It seems like this code is working as expected for regular Python scripts, but not for Python chunks in R Markdown documents. (Most likely, this is because the R Markdown chunk executor sends the code a single line at a time, whereas the standalone executor tries to process the whole input at once?) |
I think the cleanest solution would be to pre-process chunk code before submitting it, to fix up blank line indentation so that it matches the user's expectation. |
(Another alternative would be to save the last console input / current block indentation on the session side, and then use that to fix up console input -- but we'd need to have some way to differentiate between "blocks" of Python code versus a single empty line of Python code which might intentionally be terminating a block) |
Verified fixed in RStudio Desktop 2022.11.0-daily+98 on MacOS 12.5.
|
Leaving open as candidate for an automated test. I'm not sure it's worth doing so but at least to be considered. (@jonvanausdeln feel free to close if you don't think this is a good candidate.) |
can't leave this open in Elsbeth, as EG is done. I think I'll close this, as the remaining automation is already reflected in a separate ticket (859). |
System details
Steps to reproduce the problem
Create an R Markdown document, with a chunk containing the following:
Then, try to run it using the chunk Run button.
Describe the problem in detail
The empty line "ends" the function definition, and so the second
print()
statement doesn't actually become part of the code.Describe the behavior you expected
The code should be parsed and run as a single unit, so that the resulting code is:
Session Info
The text was updated successfully, but these errors were encountered: