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

Test: Python REPL Smart Send #22287

Closed
3 tasks done
anthonykim1 opened this issue Oct 23, 2023 · 11 comments
Closed
3 tasks done

Test: Python REPL Smart Send #22287

anthonykim1 opened this issue Oct 23, 2023 · 11 comments
Labels
testplan-item Test plan item/assignments for upcoming release
Milestone

Comments

@anthonykim1
Copy link

anthonykim1 commented Oct 23, 2023

Refs: #21778 #21838

Complexity: 4

Create Issue


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:

  1. 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)
  2. 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

  1. Open Python file of your choice. You can start with empty Python file and code your own Python code!
  2. Place your cursor wherever you would like in your Python code and press shift+enter.
  3. Observe that it sends minimum viable/functional code to the Python REPL.
  4. Observe that the mouse cursor is moved to the next executable block of code in the Python file.
  5. Try with code block that are multi-line, such as but not limited to multi-line dictionary, lists.
  6. 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)
  7. 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)
  8. 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
  9. 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.

@anthonykim1 anthonykim1 added the testplan-item Test plan item/assignments for upcoming release label Oct 23, 2023
@anthonykim1 anthonykim1 added this to the October 2023 milestone Oct 23, 2023
@Tyriar Tyriar changed the title Python REPL Smart Send Test: Python REPL Smart Send Oct 23, 2023
@anthonykim1 anthonykim1 removed this from the October 2023 milestone Oct 24, 2023
@bpasero bpasero removed their assignment Oct 24, 2023
@Tyriar
Copy link
Member

Tyriar commented Oct 24, 2023

I'm blocked on this by #22318

@anthonykim1
Copy link
Author

Sorry for the initial typo, but its 'OptInto' not 'OptInFrom'. in setting up settings.json

@TylerLeonhardt
Copy link
Member

Do we need to retest with the fixed setting? SHIFT+ENTER was being handled. Does this setting use a different code path for a similar feature?

@anthonykim1
Copy link
Author

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
Copy link
Author

anthonykim1 commented Oct 25, 2023

@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
Copy link
Member

Tyriar commented Oct 25, 2023

It's unclear what is going to be send exactly, for example this will send the entire while block:

Image

But this will only send the single line:

Image

So the question is why doesn't the re.search line get run alone since it's technically the "minimum functional code"

@Tyriar Tyriar removed their assignment Oct 25, 2023
@Tyriar Tyriar closed this as completed Oct 25, 2023
@Tyriar Tyriar reopened this Oct 25, 2023
@Tyriar Tyriar closed this as completed Oct 25, 2023
@johnchristopherjones
Copy link

johnchristopherjones commented Nov 15, 2023

Hi @anthonykim1! I love REPL-style development, so thank you for this feature. That said, I have two concerns. :)

Should I open issues for them?

  1. The dynamic cursor move does not leave cursor history. That is, I can't get back to my original cursor position with ⌃- (workbench.action.navigateBack).
    Example: I evaluate code with ⇧ENTER and 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.
  2. Is there any way to turn off the dynamic cursor move? For example, sometimes I just want to eval something resembling 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
Copy link
Member

Tyriar commented Nov 15, 2023

@johnchristopherjones does the go back action work instead of shift+-? It's different depending on the platform:

  • macOS ctrl+minus
  • Windows alt+left
  • Linux ctrl+alt+minus

@jicart
Copy link

jicart commented 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
Copy link
Author

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
Copy link
Author

anthonykim1 commented Nov 16, 2023

Hi @anthonykim1! I love REPL-style development, so thank you for this feature. That said, I have two concerns. :)

Hello, @johnchristopherjones
Thank you for your kind words :)

Should I open issues for them?

You may file issue/concern anytime!

  1. The dynamic cursor move does not leave cursor history. That is, I can't get back to my original cursor position with ⌃- (workbench.action.navigateBack).

This is quite interesting behavior. I will have to investigate on this.

Example: I evaluate code with ⇧ENTER and 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.
2. Is there any way to turn off the dynamic cursor move? For example, sometimes I just want to eval something resembling randint() a few times, like a hypothesis example.

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.

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.

Feel free to file request/issue on this! Will look into this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
testplan-item Test plan item/assignments for upcoming release
Projects
None yet
Development

No branches or pull requests

7 participants