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

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

Closed
brettcannon opened this issue Oct 17, 2023 Discussed in #22227 · 11 comments · Fixed by #23641
Closed

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

brettcannon opened this issue Oct 17, 2023 Discussed in #22227 · 11 comments · Fixed by #23641
Assignees
Labels
area-repl area-terminal bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on
Milestone

Comments

@brettcannon
Copy link
Member

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.

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Oct 17, 2023
@brettcannon brettcannon changed the title Unify REPL and "Run Selection/Line in Python terminal" terminals? Have "Run Selection/Line in Python terminal" work with "Start REPL" Oct 17, 2023
@karthiknadig karthiknadig added the bug Issue identified by VS Code Team member as probable bug label Oct 18, 2023
@luabud luabud added needs PR Ready to be worked on and removed triage-needed Needs assignment to the proper sub-team labels Dec 14, 2023
@karthiknadig karthiknadig added this to the June 2024 milestone Jun 20, 2024
anthonykim1 added a commit that referenced this issue Jun 21, 2024
Resolves: #22242

Attempting to keep instance of REPL. Did not end up using shell
integration for this, but shell integration and exit code will come in
handy when we have to keep track of 'opened' state of REPL instance for
cases when user wants to enter 'exit()'
DonJayamanne pushed a commit to DonJayamanne/pythonVSCode that referenced this issue Jun 24, 2024
Resolves: microsoft#22242

Attempting to keep instance of REPL. Did not end up using shell
integration for this, but shell integration and exit code will come in
handy when we have to keep track of 'opened' state of REPL instance for
cases when user wants to enter 'exit()'
@anthonykim1
Copy link

anthonykim1 commented Jun 24, 2024

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.

@anthonykim1 anthonykim1 added the verification-needed Verification of issue is requested label Jun 24, 2024
@eleanorjboyd eleanorjboyd added the verification-found Issue verification failed label Jun 25, 2024
@eleanorjboyd
Copy link
Member

Screenshot 2024-06-25 at 1 17 22 PM

@anthonykim1
Copy link

anthonykim1 commented Jun 25, 2024

@eleanorjboyd could you to toggle off switch in setting to not send to native REPL? Try shift+enter and the command 'Start Terminal REPL' then. Shift+enter (run selection) will bind to either send commands to Terminal REPL or the new REPL depending on the setting.

@rzhao271
Copy link

On Windows 11, no matter what value I use for python.REPL.sendToNativeREPL, I notice that Start Terminal REPL always creates a terminal REPL and that Shift+enter on a line always seems to send it to the Interactive Window. Therefore, steps 4 and 5 both fail.

@rzhao271 rzhao271 reopened this Jun 25, 2024
@rzhao271 rzhao271 added verified Verification succeeded and removed verification-found Issue verification failed labels Jun 25, 2024
@anthonykim1
Copy link

Had discussion with @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.

eleanorjboyd pushed a commit to eleanorjboyd/vscode-python that referenced this issue Jun 28, 2024
Resolves: microsoft#22242

Attempting to keep instance of REPL. Did not end up using shell
integration for this, but shell integration and exit code will come in
handy when we have to keep track of 'opened' state of REPL instance for
cases when user wants to enter 'exit()'
@maflAT
Copy link

maflAT commented Jul 10, 2024

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 @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.

@brettcannon
Copy link
Member Author

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

@brettcannon brettcannon reopened this Jul 10, 2024
@brettcannon brettcannon removed verified Verification succeeded verification-needed Verification of issue is requested labels Jul 10, 2024
@brettcannon
Copy link
Member Author

@anthonykim1 I reopened the issue to see if this is still an issue.

@anthonykim1
Copy link

Hi @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.

@maflAT
Copy link

maflAT commented Jul 10, 2024

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

@anthonykim1
Copy link

anthonykim1 commented Jul 10, 2024

@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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-repl area-terminal bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants