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

Very confusing (and limiting) mix of options for running python terminal/repl #7206

Closed
memeplex opened this issue Sep 5, 2019 · 7 comments
Closed
Assignees
Labels
area-terminal feature-request Request for new features or functionality

Comments

@memeplex
Copy link

memeplex commented Sep 5, 2019

Environment data

  • VS Code version: 1.37.1
  • Extension version: 2019.9.34474
  • OS and version: Ubuntu 19.04
  • Python version : 3.7.3
  • Type of virtual environment used: None
  • Relevant/affected Python packages and their versions:
  • Jedi or Language Server?: Microsoft Language Server

There are at least four options:

  1. Python: Create Terminal (command)
  2. Python: Start REPL (command)
  3. Run Selection/Line in Python Terminal (context menu)
  4. Run Python File in Terminal (context menu)

Expected behaviour

At least, this use case should be supported: the user opens a python terminal / REPL and later sends a selection to this same REPL.

Also IMHO 1 and 2 are very much overlapping and it's not clear at all why the user would create a terminal named Python without a python REPL in it and that won't even be used by 3 or 4.

Actual behaviour

Option number 1 creates a shell terminal without running any python REPL in it. This is very confusing per se, but worse: the terminal is named Python but still is not used by 3 nor by 4.

Options 3 and 4 don't use the terminal created by 1 nor the REPL created by 2, but their own python terminal (also named Python).

This means that there is no way to open a REPL, do some exploration/interactive stuff and then send a selection to it. The only way to open a REPL that would later accept selections is to open it sending a selection (or file). This forces the user to send a dummy selection in order to open a selection-accepting REPL/terminal.

Steps to reproduce:

I think this is clear from the above description. There are many scenarios. Here is one:

  1. Open a python terminal
  2. This starts a shell terminal named Python
  3. Open a python REPL
  4. This indeed starts a REPL named REPL
  5. Select some python code and send it to the terminal
  6. This creates a third python terminal, also named Python
@memeplex memeplex added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Sep 5, 2019
@memeplex
Copy link
Author

memeplex commented Sep 5, 2019

The following is quoted from the user guide and seems to imply that selection should be sent to the REPL created by the user:

The command opens the Python Terminal if necessary; you can also open the interactive REPL environment directly using the Python: Start REPL command. (Initial startup might take a few moments especially if the first statement you run is an import.)

On first use of the Python: Run Selection/Line in Python Terminal command, VS Code may send the text to the REPL before that environment is ready, in which case the selection or line is not run. If you encounter this behavior, try the command again when the REPL has finished loading.

Now, the REPL created by the user is named REPL, the one created by sending a selection is called Python, and they are never the same one. Given what is documented, the behavior is not only inconvenient and confusing, as described in my previous comment, but also a bug.

@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 5, 2019
@luabud
Copy link
Member

luabud commented Sep 6, 2019

Hi @memeplex, thank you for this feedback! So if I understood correctly, you would expect the "Python: Create Terminal" to create a REPL instead of a blank terminal, since the command name starts with "Python", is that correct?

Right now the behaviour of the "Python: Run Selection/Line in Python Terminal" is to create a new terminal and start the REPL when it's run for the first time, and after that it'll keep sending the selections to the same one. You'll notice that if you quit that REPL, this command will still send selections to the terminal as the extension has no information if there's a REPL running on the terminal or not. I agree that this experience is not ideal, but meanwhile we've been putting more efforts to give a great interactive experience with the Python Interactive Window ("Python: Show Python Interactive Pane" command). Have you tried this with the extension already? If not, please do give it a try and let us know if it doesn't work for your workflow.

Again, thank you so much for taking the time to provide this feedback!

@memeplex
Copy link
Author

Hi @luabud, thank you for your prompt reply!

I think it could be simplified to just these three actions:

  1. Lauch REPL/Python terminal (which should be the same thing): the user launches a new python process attached to a terminal.
  2. Run selection (or current line) in REPL/Python terminal: the selected code in the current editor (or the current line if no selection is active) is send to the-currently-selected or the-last-selected or a-new REPL/Python terminal, in that order. I mean, if there is a currently selected REPL, use it, if not but there is at least a running REPL, run the one more recently selected by the user, otherwise run a new one.
  3. Run current file in REPL/Python terminal: as 2 but doing an exec of the file in the REPL/Python terminal instead of "copy&pasting" the code.

Something along those lines is done by other editors with python support I used in the past. More sophisticated approaches are also possible, like connecting an editor to a specific REPL, but I think the above suggestion is closer to what you have now and still more intuitive, simple and powerful (the last one because it allows for a workflow better mixing code from a file and code directly entered into the REPL).

@memeplex
Copy link
Author

Btw, the interactive python window is ok, but at this moment is limited to one instance. Besides it requires launching a jupyter kernel, which could be overkilling for quickly sending a selection to a REPL. Moreover, some things (like breakpoint() and help, ?, ??) just work better in good old terminal python/ipython.

@luabud luabud added area-terminal needs decision feature-request Request for new features or functionality and removed triage bug Issue identified by VS Code Team member as probable bug labels Sep 13, 2019
@luabud
Copy link
Member

luabud commented Sep 13, 2019

@memeplex I see, thank you for the suggestion! I marked this issue as an "enhancement" and "needs decision", so we can have a conversation about your idea 😊

cc @ronglums for feedback on the interactive window in the comment above

@eElor
Copy link

eElor commented Oct 11, 2019

Please have a look at this comment on #2997.

@karthiknadig
Copy link
Member

Closing this as Duplicate of #2997

@ghost ghost removed the needs proposal Need to make some design decisions label Dec 3, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 7, 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
Projects
None yet
Development

No branches or pull requests

5 participants