-
Notifications
You must be signed in to change notification settings - Fork 227
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
commented out code in python can cause an IndentationError #447
Comments
Does the indent on the commented line matter? (would it work if it were indented like the rest of the body?) Also, there's an "escape hatch" for custom escapes: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md#how-to-override-language-transformations Let me know |
I didn't quite understand the question. If you meant, does an IndentationError occur if the code is commented out like this: for i in range(10):
print(i, end=' ')
# print(i * 2, end=' ')
print(i * i) Then no, it does not arise. function! _EscapeText_python(text)
...
return substitute(dedented_lines, add_eol_pat, "\n", "g") The newline is added focusing on the indentation, not paying attention to whether it is a code or a comment. If the indentation of the comment does not match the rest of the text, a line feed will be added, which will cause an IndentationError when sending further text. If your question is whether the proposed change to the empty_lines_pat template will work with different indents, then yes, such a template will delete all lines containing only a comment, regardless of the indentation. I think there is no point in sending comments to the REPL. The interpreter ignores them anyway, and the person reads them in the editor. As for the SlimeOverride_Escape Text_#{language} function, I think this path is intended to be customized to the user's "taste". Tastes can be individual. But, I suppose, no one wants the results of calling a program to differ depending on whether it was executed in the interpreter or sent via vim-slime |
Since I'm not a Python user myself, I'm hesitant to change how its substitutions are made. Especially given how long this code has been around (which hints that it works for most people 🤔 ) In vim, I've been using nerdcommenter which toggles comments at the proper indent level. In neovim, the If you want to take this on, I would recommend you |
Example:
Maybe it's better to consider comments as empty lines?
To do this, in ftplugin/python/slime.vim: _EscapeText_python() can replace
with
The text was updated successfully, but these errors were encountered: