-
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 Selected Text in Active Terminal gives IndentationError with IPython #8945
Comments
A few more notes: The regular Python prompt is OK. Also, I've used IPython + Run Selected Text with my Windows machine for quite a few months with no issues. I've recently moved to a Mac and I've run into this bug just now. I cannot test with Windows at the moment so I'm not sure if this is a Windows vs. Mac issue, or a general regression. |
I've checked this on Windows (the same VSCode & Python extension versions), the problem is not there. So possibly it's macOS specific? |
Thanks for getting in touch with us about this, @iutlu. The |
Thanks. I've experimented a bit more, this time with the command from the Python extension ( Specifically if you do the following:
Now, the So my question is,
Thank you again for your time! |
Ah, thanks for the clarification. We'll look into this further. |
@ericsnowcurrently , based on @iutlu last response, this doesn't sound like it has to do with ipython, but rather with what is being sent to the terminal from the editor. This doesn't look like a datascience or ipython issue. |
I'll take a look then. |
@iutlu, Yeah, the extension calls essentially the same API to "run selected text ..." that VS Code uses itself. The key differences are:
Note that the extension's |
All that said, if your intention is still to run selected text in the terminal (where you are running ipython) then it sounds like the problem is that you're running into unexpected indents when the text is pasted to the terminal. Is that right? If this is the same code that you were using on Windows is it possible that there are hidden carriage-return characters still there that are causing a problem? |
@ericsnowcurrently Thank you for looking into this. I'm aware of the Interactive Window but I really prefer a simple IPython prompt (faster; can be placed at the bottom; doesn't take much space; I don't use inline-plots or cells anyways).
Yes, I receive unexpected indents when I use any of the two commands. A manual copy-and-paste is fine.
I have tried the LF and CRLF versions of the same 3-line py file on both Windows and Mac, with no differences: a manual copy-and-paste always works on both platforms. The Although I'm not 100% sure, I think things did actually work as expected when I first set up VSCode on the Mac. I'll try to test with the recent few releases of VSCode and/or the extension see if/when things broke. |
@iutlu, any updates on what you found when you tried earlier versions? |
Hi, I've been a bit busy these past few days -- I'll try to look at it over the weekend |
We'll look into it. I suspect there is something fishy going on with IPython. The extension literally pastes the highlighted text into the terminal. This works fine in the REPL for the same interpreter in which we run IPython. That's why I think IPython is responsible. We'll find out and if there's anything we can do about it then we'll work on it. (Note that the extension does a little normalization to make sure line feeds and unicode are right. However, I verified that the example text from above does not get changed.) |
I also noticed the indentation errors when using ipython in WSL terminal, but not when in cmd, powershell, and git bash |
I face the same issue with the terminal and python (not ipython) when I want to process multi-line. The behavior is erratic. Sometimes the list passes through just fine, other times it does not. I have a multi-line(300 lines) list of tuples of strings. At some point one of the strings (randomly) is not read correctly and a syntax error is thrown followed by series of Indentation Errors. Details of my version: Version: 1.44.2 P.S.: Everything works fine in the interactive window, but i prefer the terminal since it's way faster |
Same issue as @ECon87 and @iutlu on Mac OS, The sending code to "interactive python" (i.e. The code on the editor is def myf(x):
""" doc string
"""
return x |
Same issue for me on ubuntu |
@ericsnowcurrently I've tested this with VSCode & Python extension releases from around November 2019 (which is when I'd thought this might have been working). Unfortunately still seeing the same issue with IndentationError. I must have been misguided in thinking this actually worked at some point. (Apologies for the (great) delay on this feedback) |
Same issue was well |
Try to toggle ipython's %autoindent into OFF. https://ipython.org/ipython-doc/3/interactive/reference.html#autoindent
The above is out of date, but useful. |
Toggling |
I'm experiencing now the same error related in this issue, but it did not happen in an recent past. I've updated Anaconda in the last month to use Python 3.9. That's the only modification from the point I believe this error did not occur. Set Additional infos:
I'm on Windows 10.0.17763.1935, Anaconda 2021.11, Python 3.9, IPython 7.29.0 |
Facing same issues in vscode 1.72 Macos |
Facing same issues in vscode 1.80.0 on Windows 10 Enterprise |
Hello folks, we have launched native repl which provides intellisense and syntax highlighting in editor-style based REPL Will be closing this against: #17172 but please feel free to go and upvote the issue to show interest. |
Environment data
"python.jediEnabled"
set to; more info How to update the language server to the latest stable version #3977): Language ServerExpected behaviour
Selecting some text and running the command "Terminal: Run Selected Text In Active Terminal" properly pastes the selection to an IPython console.
Actual behaviour
IndentationError is received.
Steps to reproduce:
The following error is received:
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)No output
Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
; turn on source maps to make any tracebacks be useful by runningEnable source map support for extension debugging
)No output
The text was updated successfully, but these errors were encountered: