You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
REPL Smart Shift+Enter and Dynamic Smart Cursor (#21779)
There are two Feature Requests from: #18105#21838
They are grouped together to provide the smoothest experience: when user
wants to press shift+enter and smoothly move between each executable
Python code block without having to manually move their cursor.
#19955 (For Execute line/selection and advance to next line, referred to
as dynamic smart cursor hereby)
Open Issue: #21778#21838
Steps in implementing REPL Smart Send (smart shift+enter to the REPL)
and dynamic cursor move aka. Move to Next Line (next executable line of
code to be more precise):
1. Figure out the workflow of where things start and run when user
clicks on run selection/line
2. Send the content of selection & document to the Python Side from
Typescript side.
3. Respect and follow previous logic/code for EXPLICIT selection (user
has highlighting particular text they want to send to REPL), but
otherwise, use newly created smart send code.
4. Receive content of document & selection in Python Side
5. Use AST (From Python standard library) to figure out if selection if
selection is part of, for example, dictionary, but look for nodes and
how each relates to the top level. If some selection is, for example
part of a dictionary, we should run the whole dictionary. Look at how to
do this for all top level, so that we run the Minimum Viable Block
possible. (For example, if user selects part of a dictionary to run in
REPL, it will select and send only the dictionary not the whole class or
file, etc)
6. Receive the commands to run in typescript side and send it to the
REPL
7. After the user has ran shift+enter(non highlight, meaning there was
no explicit highlight of text), thus the incurring of smart send, and we
have processed the smart selection, figure out the "next" executable
line of code in the currently opened Python file.
8. After figuring out the "next" line number, we will move user's cursor
to that line number.
- [x] Additional scope for telemetry EventName.EXECUTION_CODE with the
scope of 'line' in addition to differentiate the explicit selection
usage compared to line or executable block.
- [x] Drop 3.7 support before merging since end_line attribute of the
AST module is only supported for Python version 3.8 and above.
- [x] Python tests for both smart selection, dynamic cursor move.
- [x] TypeScript tests for smart selection, dynamic cursor move.
Notes:
* To be shipped after dropping Python3.7 support, since end_lineno,
which is critical in smart shift+enter logic, is only for Python version
GREATER than 3.7 Update (9/14/23: Python 3.7 support is dropped from the
VS Code Python extension: #21962)
* Code in regards to this feature(s) should be wrapped in standard
experiment (not setting based experiment)
* Respective Telemetry should also be attached
* EXPLICIT (highlight) selection of the text, and shift+enter/run
selection should respect user's selection and send AS IT IS. (When the
user selects/highlight specifically what they want to send, we should
respect user's selection and send the selection as they are selected)
* Smart Shift+Enter should be shipped together with dynamic smart cursor
movement for smoothest experience.
This way user could shift+enter line by line (or more accurately top
block after another top block) as they shift+enter their code.
* Be careful with line_no usage between vscode and python as vscode
counts line number starting from 0 and python ast start as normal
(starts from line 1)) So vscode_lineno + 1 = python_ast_lineno
---------
Co-authored-by: Karthik Nadig <[email protected]>
Copy file name to clipboardExpand all lines: package.nls.json
+1
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,7 @@
41
41
"python.experiments.pythonPromptNewToolsExt.description": "Denotes the Python Prompt New Tools Extension experiment.",
42
42
"python.experiments.pythonTerminalEnvVarActivation.description": "Enables use of environment variables to activate terminals instead of sending activation commands.",
43
43
"python.experiments.pythonTestAdapter.description": "Denotes the Python Test Adapter experiment.",
44
+
"python.experiments.pythonREPLSmartSend.description": "Denotes the Python REPL Smart Send experiment.",
44
45
"python.formatting.autopep8Args.description": "Arguments passed in. Each argument is a separate item in the array.",
45
46
"python.formatting.autopep8Args.markdownDeprecationMessage": "This setting will soon be deprecated. Please use the [Autopep8 extension](https://marketplace.visualstudio.com/items?itemName=ms-python.autopep8). <br>Learn more [here](https://aka.ms/AAlgvkb).",
46
47
"python.formatting.autopep8Args.deprecationMessage": "This setting will soon be deprecated. Please use the Autopep8 extension. Learn more here: https://aka.ms/AAlgvkb.",
0 commit comments