Open szymonhennel opened 2 months ago
Hello @szymonhennel Thank you for filing the issue and I truly appreciate your kind words and appreciation here. You made great points here and I appreciate the detailed info here.
Couple things here, but let's try to unwrap and discuss this step by step:
If you are in the interactive window mode, you will see colorized output from the iPyKernel itself coming from Jupyter:
It looks like you are satisfied enough with the output that native REPL generates and do not necessary need the one from Jupyter. If that is the case, this can be a great feature request idea that you can post with the 'feature request' tag. I can see this being totally valid request.
I am also wondering if you can change interpreter via command palette (ctrl/cmd + shift + p) 'Select Interpreter' and try opening the Native REPL again and see your desired effect? Instead of changing the kernel via clicking on 'Python REPL'
Hi @anthonykim1 thank you for answering and sorry for taking a long time to come back to you, I will answer by tomorrow.
Hey @anthonykim1, thank you for the context! Came across the same issue, happy it was brought up! To answer your question, changing the interpreter via the command palette (ctrl/cmd + shift + p) has zero effect on the issue, it is still reproducible.
It seems like what needs to be fixed here is the command that sends the code over to the interactive window, everything else works fine.
I personally think that using a Jupyter-provided Interactive Window has a nicer workflow than the ipynb.
Tagging @IanMatthewHuff as an engineer involved in making this feature.
the very moment you decide to pick a "kernel" yourself instead of Python REPL, it seems that Jupyter extension switches your mode from Native REPL to Interactive Window
IIUC, this is what the user is asking for, but doesn't quite work - you can change the kernel, but using sendToNativeRepl will switch the kernel back to python's.
The user should be able to select a different kernel to use here, and would actually provide a workaround for https://github.com/microsoft/vscode-jupyter/issues/15988
I see, with the explanation + video made it super clear. Thanks!
The smoothest transition I can think of would be: Perhaps we need to detect when user has switched their kernel from (native REPL to IW) and automatically change the keybinding (of shift+enter) to send to IW instead of Python Native REPL?
If we detect user change their kernel back to native REPL (Im not sure if this is possible), we would again change/revert the shift+enter keybinding to send command to native REPL instead of IW.
Does this sound reasonable?
I think a much simpler solution would just be to not run the selectKernel
command if the editor was already opened - allow the user to use a different kernel in the python REPL editor.
I was facing a similar issue, but I managed to change it so it doesn't use the Python REPL editor every time I press Shift+Enter
by doing the following:
TL;DR: Change jupyter.interactiveWindow.textEditor.executeSelection
to true
using the Visual Studio Code Settings UI. This made it start using my kernel as the default option.
Steps: Open Settings UI:
Ctrl+Shift+P
, search for Settings UI.Search for the Setting:
jupyter interactive window text editor execute selection.
Enable the Setting:
Jupyter: Interactive Window Text Editor Execute Selection.
Hey @anthonykim1, this issue might need further attention.
@szymonhennel, you can help us out by closing this issue if the problem no longer exists, or adding more information.
Type: Bug
Behavior
Context
Upon starting a native python REPL, the default kernel "Python REPL" is active. With the setting
"python.REPL.sendToNativeREPL": true
, Shift+Enter sends code from the editor to the REPL. If the user is happy working with the default kernel, everything is fine an no issues occur. If the user wants to use a different kernel, this can be achieved by clicking on the kernel button in the top right corner of the native REPL pane. The kernel selection works as expected, and the selected kernel remains active without issues as long as code is entered and executed manually.Where the bug manifests
The bug is that when a non-default kernel is selected and code is sent to the REPL from the editor pane by Shift+Enter, this action triggers a change of the kernel back to "Python REPL", and the code sent is interpreted by this default kernel. This makes the setting "Send to active REPL" unusable if the user works with a virtual environment.
Expected behavior
The kernel selection should not be affected by sending code to the REPL.
Environment
Python 3.12.5 on Windows 11 Pro 23H2, virtual environment managed by poetry, python extension v2024.12.3.
User settings
I have checked that any combination of the settings
"interactiveWindow.executeWithShiftEnter"
,"python.terminal.activateEnvInCurrentTerminal"
and"python.terminal.activateEnvironment"
do not affect the behavior described above.How to reproduce:
"python.REPL.sendToNativeREPL": true
.And since this is my first time interacting with this community I take this opportunity to thank you all for providing this awesome extension.