Skip to content
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

Support sending selection to terminal using using IPython #17690

Closed
alandema opened this issue Oct 10, 2021 · 4 comments
Closed

Support sending selection to terminal using using IPython #17690

alandema opened this issue Oct 10, 2021 · 4 comments
Assignees
Labels
area-terminal feature-request Request for new features or functionality needs community feedback Awaiting community feedback

Comments

@alandema
Copy link

Environment data

  • VS Code version: 1.61.0 (user setup)
  • Extension version: 2021.10.1317843341
  • OS and version: W10 21H1
  • Python version (& distribution if applicable, e.g. Anaconda): Miniconda python 3.9.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Value of the python.languageServer setting: Pylance

Expected behaviour

with shortcut as:
{
"key": "ctrl+enter",
"command": "python.execSelectionInTerminal"
}

and using an IPython console:
"python.terminal.launchArgs": [
"-m",
"IPython"
],

When Ctrl + Enter, the expected is to send the lines to terminal and execute it as is.

Actual behaviour

When defining a function, the indentation goes crazy and for particular codes the console returns an indentation error. The same code works fine if executed or debugged or used in IPython in another IDE or running in the vanilla Python console.

Steps to reproduce:

vscode

@alandema alandema added bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team labels Oct 10, 2021
@karthiknadig karthiknadig added area-terminal triage and removed triage-needed Needs assignment to the proper sub-team labels Oct 11, 2021
@karrtikr karrtikr added investigating We are looking into the cause of the issue and removed triage labels Oct 11, 2021
@karrtikr
Copy link

Thanks for the bug report! We just wanted to quickly acknowledge we received it and we will triage this as soon as we can.

@karrtikr
Copy link

karrtikr commented Oct 13, 2021

Hi @alandema , this looks like an issue with IPython module itself. Extension simply sends the selection to terminal. Regardless of the extension, if you attempt to copy paste this

def soma(a,b):
    a=1
    for i in range(10):
        print('a')

in a IPython, it results in extra indentation resulting in an error:
image

I think it is because in IPython, blocks are automatically indented:

image

and IPython is pasting the code line by line instead of directly pasting it, due to which blocks are extra indented.

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Oct 13, 2021
@karrtikr karrtikr reopened this Oct 13, 2021
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Oct 13, 2021
@karrtikr karrtikr removed the triage-needed Needs assignment to the proper sub-team label Oct 13, 2021
@karrtikr karrtikr changed the title Indentation error using IPython Support sending selection to terminal using using IPython Oct 13, 2021
@karrtikr karrtikr added feature-request Request for new features or functionality needs community feedback Awaiting community feedback and removed bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster investigating We are looking into the cause of the issue labels Oct 13, 2021
@karrtikr
Copy link

karrtikr commented Oct 13, 2021

See the following for the workaround: #8945 (comment), which gives a link on how to turn autoindent off.

@karrtikr
Copy link

Closing as dup of #8945, very similar to #17172.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-terminal feature-request Request for new features or functionality needs community feedback Awaiting community feedback
Projects
None yet
Development

No branches or pull requests

3 participants