Repository navigation
Test: Python REPL Smart Send #22287
Copy link
Copy link
Closed
Labels
Milestone
Description
- macOS Benjamin Pasero (@bpasero)
- linux TylerLeonhardt
- windows Daniel Imms (@Tyriar)
Complexity: 4
Thank you in advance for testing REPL Smart Send feature!
Please let me know if you have any questions, problems, comments.
I hope you enjoy this feature whenever you want to shift+enter through your Python file!
Background Information
REPL Smart Send consists two integrated features(referenced above) that are shipped together to provide smoother Python REPL experience with Shift+Enter:
- Smart Selection: User (who is not highlighting/explicitly selecting any text) should be able to have their mouse cursor in some point of their Python code, and we should be able to detect, send minimum functional code to the REPL when Shift+Enter is pressed.
- Dynamic Cursor Move: When user shift+enters with no highlight/no explicit selection of the text, mouse cursor should move to next executable code in the currently opened Python document.
Setup:
- Make sure you are using Python3.8 or above. This feature will only work for Python3.8 and above. (3.8 is the minimum official support that VS Code Python repository have at the moment)
- Make sure you have pythonREPLSmartSend experiment enabled. You can do this by editing your settings.json to have
"python.experiments.enabled": true,
"python.experiments.optInto": ["pythonREPLSmartSend"],
Steps
- Open Python file of your choice. You can start with empty Python file and code your own Python code!
- Place your cursor wherever you would like in your Python code and press shift+enter.
- Observe that it sends minimum viable/functional code to the Python REPL.
- Observe that the mouse cursor is moved to the next executable block of code in the Python file.
- Try with code block that are multi-line, such as but not limited to multi-line dictionary, lists.
- Try shift entering AT higher level code block such as where functions are defined with: """def whatever_function:""" (cursor should be exactly at declaration of top level block you want to send)
- Observe that whole higher level code block (in this case, function) is sent to the REPL and cursor is moved appropriately to after the block shift entered on (in this case cursor should be on executable code presented after whatever_function)
- If you press shift+enter inside higher block of code (in this case, inside the function), it should only send that independent and hence the minimum viable code (in this case, print statement) to the REPL
- Play around with any Python code block you want to test with, and see if appropriate "smart" code block is sent to the REPL, as well as the appropriate mouse cursor move you will see in your file editor window!
Note: Smart Send will only work when there is NO EXPLICIT selection, meaning NO EXPLICIT highlighting of the text.
Reactions are currently unavailable
Activity
[-]Python REPL Smart Send[/-][+]Test: Python REPL Smart Send[/+]Tyriar commentedon Oct 24, 2023
I'm blocked on this by #22318
anthonykim1 commentedon Oct 24, 2023
Sorry for the initial typo, but its 'OptInto' not 'OptInFrom'. in setting up settings.json
TylerLeonhardt commentedon Oct 24, 2023
Do we need to retest with the fixed setting?
SHIFT+ENTERwas being handled. Does this setting use a different code path for a similar feature?anthonykim1 commentedon Oct 25, 2023
Hi TylerLeonhardt , No need to retest if you were able to get smart send results with just the "python.experiments.enabled": true, " Thank you!
anthonykim1 commentedon Oct 25, 2023
Daniel Imms (@Tyriar) Explained further on the issue you made, but long story short, Python2 code was messing up the parsing for your Python test file you were using. Smart Send should work on Python3! Thanks
Tyriar commentedon Oct 25, 2023
It's unclear what is going to be send exactly, for example this will send the entire while block:
But this will only send the single line:
So the question is why doesn't the
re.searchline get run alone since it's technically the "minimum functional code"johnchristopherjones commentedon Nov 15, 2023
Hi Anthony Kim (@anthonykim1)! I love REPL-style development, so thank you for this feature. That said, I have two concerns. :)
Should I open issues for them?
⌃-(workbench.action.navigateBack).Example: I evaluate code with
⇧ENTERand my cursor jumps forward. When I hit⌃-, I expect my cursor to jump back to where I hit⇧ENTER. There's currently no way to get back to the exact position I was at before.randint()a few times, like a hypothesis example.Relatedly, can the work done here be used to make "Expand Selection" (
editor.action.smartSelect.expand) work better? Before this experiment I'd use "Expand Selection" with "Run Selection/Line in Python Terminal". It's pretty rough around the edges.Tyriar commentedon Nov 15, 2023
John Jones (@johnchristopherjones) does the go back action work instead of shift+-? It's different depending on the platform:
jicart commentedon Nov 16, 2023
It seems this was enabled for me after the last vscode update, and I can't find how to disable it.
I've looked for a specific configuration using the search, but couldn't find it.
I've tried setting:
"pythonREPLSmartSend": false,but it changed nothing. Also it says it's an "Unknown Configuration Setting".
I also asked copilot, but it just answered nonsense.
I just want the old behavior back.
anthonykim1 commentedon Nov 16, 2023
Hi jicart. You can disable the experiment by going to "~/Library/Application Support/Code - Insiders/User/settings.json"
and then including "python.experiments.optOutFrom": ["pythonREPLSmartSend"],
anthonykim1 commentedon Nov 16, 2023
Hello, John Jones (@johnchristopherjones)
Thank you for your kind words :)
You may file issue/concern anytime!
This is quite interesting behavior. I will have to investigate on this.
Yes! Setting for disabling Smart send (smart selection + dynamic cursor move) is coming soon.
Right now, you can opt out from by adding "python.experiments.optOutFrom": ["pythonREPLSmartSend"], in your user settings.json as mentioned above.
Feel free to file request/issue on this! Will look into this.