Skip to content

Have "Run Selection/Line in Python terminal" work with "Start REPL" #22242

Closed

Description

Discussed in #22227

Originally posted by cbrnr October 16, 2023
With the new smart Shift+Enter feature, it is now very convenient to run a line (or a selection of lines) of code in the interactive interpreter. After hitting Shift+Enter (or selecting "Run Selection/Line in Python terminal"), a new terminal titled "Python" opens with the interactive interpreter, which accepts intput from this command.

However, I was wondering if I can manually start this terminal (i.e., the Python one, which is connected to the "Run Selection/Line in Python terminal" action). I found the "Python: Start REPL" action, which launches the interactive interpreter, but this terminal does not accept input from Shift+Enter.

Would it be possible to unify these two ways of starting the interactive Python interpreter and/or running code? Or maybe let users decide to which terminal they want to send their Shift+Enter commands? This would be very convenient, because right now the only way to kickstart the interpreter for sending commands is to actually send the first line of code.

Activity

  1. changed the title [-]Unify REPL and "Run Selection/Line in Python terminal" terminals?[/-] [+]Have "Run Selection/Line in Python terminal" work with "Start REPL"[/+] on Oct 17, 2023
  2. added
    needs PRReady to be worked on
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Dec 14, 2023
  3. anthonykim1 commented on Jun 24, 2024

    @anthonykim1

    Verification steps:

    1. Please download latest pre-release version of the Python extension
    2. In Python file of your choice, Shift+enter or chose Run/Selection/Line in Python Terminal to send your Python command to Python Terminal REPL
    3. Open command palette and trigger Start Terminal REPL
    4. Observe that additional Python Terminal REPL is NOT created
    5. Try in reverse order (Start Terminal REPL first), and observe additional REPL is not created.
  4. 5 remaining items

  5. anthonykim1 commented on Jun 25, 2024

    @anthonykim1

    Had discussion with Raymond Zhao (@rzhao271) Essentially shift+enter was opening Interactive Window provided by Jupyter (with conda environment in his case), not the new Python REPL because of the setting
    Screenshot 2024-06-25 at 3 52 59 PM was enabled. In this case, shift+enter would always send things to Interactive Window instance provided by Jupyter.

  6. maflAT commented on Jul 10, 2024

    @maflAT

    Should this be live?
    It is not working for me.
    I tried with version 2024.10.0 and with pre-release 2024.11 and I still see the same behaviour that Eleanor Boyd (@eleanorjboyd) posted.
    Shift + Enter opens the new Python REPL but the "Python: Start Terminal REPL" command still opens the terminal window.
    I tried toggling the "Send to native REPL" option on and off, and i have Jupyter disabled. In fact, I don't even have the Jupyter extension installed.

  7. brettcannon commented on Jul 10, 2024

    @brettcannon
    MemberAuthor

    Markus (@maflAT) yes, it should be in the latest release.

  8. brettcannon commented on Jul 10, 2024

    @brettcannon
    MemberAuthor

    Anthony Kim (@anthonykim1) I reopened the issue to see if this is still an issue.

  9. anthonykim1 commented on Jul 10, 2024

    @anthonykim1

    Hi Markus (@maflAT)
    correct, so when you run "Python: Start Terminal REPL", it SHOULD open the terminal window regardless of your settings enabled for native REPL.
    We have renamed the previously "Python: Start REPL" into "Python: Start Terminal REPL" and plan to add "Python: Start Native REPL" for the new REPL itself.

    I believe everything is as expected if I didn't miss anything, but feel free to ping me again. Terminal REPL refers to the traditional ">>>" REPL you would get in the bottom of the VS Code editor.

    Shift+enter will bind send commands either ONE of the Terminal REPL or the Native REPL depending on your setting. (Please make sure to check both the user and workspace setting for this).

    You should be able to trigger Terminal REPL from the command palette regardless of this setting, but currently no way to trigger Start Native REPL without enabling setting and manually shift+enter on a Python file (this will come soon!)

    Jupyter should not be involved in either of these scenario, so I'm bit lost on the context there. It should say "Python REPL" on the top right hand side of the editor if the native REPL gets launched.

  10. maflAT commented on Jul 10, 2024

    @maflAT

    Oh, I see. I misunderstood then.
    I thought there should already be a command for the new REPL.
    Sorry

  11. anthonykim1 commented on Jul 10, 2024

    @anthonykim1

    Markus (@maflAT) Great, yes not at the moment but this should be coming soon! - thanks for your feedback. Will let you know when we push this out on a PR, so you can give it a try.

  12. locked as resolved and limited conversation to collaborators on Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-replarea-terminalbugIssue identified by VS Code Team member as probable bugneeds PRReady to be worked on

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions