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

when expression for command Python: Run Selection/Line in Python REPL contains config.python.REPL.sendToNativeREPL which should not be there #23733

Closed
hanqi-monarch opened this issue Jul 3, 2024 · 1 comment
Assignees
Labels
area-repl info-needed Issue requires more information from poster

Comments

@hanqi-monarch
Copy link

hanqi-monarch commented Jul 3, 2024

Type: Bug

This is my default when expression
config.python.REPL.sendToNativeREPL && editorTextFocus && !jupyter.ownsSelection && !notebookEditorFocused && editorLangId == 'python' && activeEditor != 'workbench.editor.interactive'

My issue is with config.python.REPL.sendToNativeREPL
By default it is false. How would users know that shift+enter for Python: Run Selection/Line in Python REPL requires that setting to be checked without knowledge of investigating when expression?

Another inconsistency is all smart send demos i see online are sending to the terminal. To reproduce that, i had to delete config.python.REPL.sendToNativeREPL && from the when expression, or else it will try to send to the Python REPL and break in 2 ways.

Firstly, it is not sending to terminal like demos but to Python REPL
Secondly, it is not printing the full string

Traceback (most recent call last):
  File "/home/user/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/python_server.py", line 117, in exec_user_input
    retval = callable(user_input, user_globals)
  File "<string>", line 1
    jumps over the lazy dog"""
    ^
IndentationError: unexpected indent

I am testing smartsend using multiline string below. If smart send works, i can place my cursor on both 1st and 2nd line of string and it should print properly. This only worked when I delete config.python.REPL.sendToNativeREPL from the when expression, AND uncheck Python: REPL: Send to Native REPL.

print(
    """quick brown fox 
    jumps over the lazy dog"""       
)

Is this expected behavior of smart send?

def add(num1, num2):
    return num1 + num2

If i place the cursor on return line and do shift+enter i get SyntaxError: 'return' outside function. I expected it to work.
If i place the cursor on def add line, it does load the function properly.

In both cases the cursor will jump to the next code section so that's good.


Summary

To summarize, i'm asking whether config.python.REPL.sendToNativeREPL should by default not be added to the when expression?

If it should be there, why the inconsistency with demos showing smart send outputting to terminal while this default setting is outputting to Python REPL and doesn't print the whole multiline string which smart send should do.

Extension version: 2024.8.1
VS Code version: Code 1.90.2 (5437499feb04f7a586f677b155b039bc2b3669eb, 2024-06-18T22:34:26.404Z)
OS version: Windows_NT x64 10.0.22631
Modes:
Remote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2

  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.10
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

terminal
• activateEnvironment: false

Installed Extensions
Extension Name Extension Id Version
Black Formatter ms-python.black-formatter 2024.2.0
C/C++ ms-vscode.cpptools 1.20.5
C/C++ Extension Pack ms-vscode.cpptools-extension-pack 1.3.0
C/C++ Themes ms-vscode.cpptools-themes 2.0.0
CMake twxs.cmake 0.0.17
CMake Tools ms-vscode.cmake-tools 1.18.42
Copy Breadcrumbs scott-blair.copy-breadcrumbs 0.0.1
Data Wrangler ms-toolsai.datawrangler 1.4.1
Docker ms-azuretools.vscode-docker 1.29.1
GitHub Copilot GitHub.copilot 1.208.0
GitHub Copilot Chat GitHub.copilot-chat 0.16.1
GitLens — Git supercharged eamodio.gitlens 15.1.0
Hex Editor ms-vscode.hexeditor 1.10.0
JavaScript Debugger ms-vscode.js-debug 1.90.0
Jupyter ms-toolsai.jupyter 2024.5.0
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.18
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow 0.1.6
Live Server ritwickdey.LiveServer 5.7.9
Live Share ms-vsliveshare.vsliveshare 1.0.5932
Makefile Tools ms-vscode.makefile-tools 0.9.10
Perl richterger.perl 2.6.2
Pylance ms-python.vscode-pylance 2024.6.1
Python ms-python.python 2024.8.1
Python Debugger ms-python.debugpy 2024.6.0
Rainbow CSV mechatroner.rainbow-csv 3.12.0
Render Line Endings medo64.render-crlf 1.8.1
ROS ms-iot.vscode-ros 0.9.2
SQLTools mtxr.sqltools 0.28.3
Sublime Text Keymap and Settings Importer ms-vscode.sublime-keybindings 4.1.10
SVG-Viewer Dheovani.svg-viewer 1.1.2
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.9
VSCode Great Icons emmanuelbeziat.vscode-great-icons 2.1.105
System Info
Item Value
CPUs 13th Gen Intel(R) Core(TM) i7-13700HX (24 x 2304)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.75GB (14.76GB free)
Process Argv --crash-reporter-id 0ccda5b0-9e9d-4556-a7a0-5bd5b4595958
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu-20.04
OS Linux x64 5.15.153.1-microsoft-standard-WSL2
CPUs 13th Gen Intel(R) Core(TM) i7-13700HX (24 x 0)
Memory (System) 15.49GB (12.34GB free)
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonnoceb:30805159
asynctok:30898717
pythonregdiag2:30936856
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
jchc7451:31067544
chatpanelc:31048052
dsvsc021:30996838
01bff139:31013167
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
newcmakeconfigv2:31071590
legacy_priority:31082724

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jul 3, 2024
@hanqi-monarch hanqi-monarch changed the title when expression for command Python: Run Selection/Line in Python REPL makes no sense when expression for command Python: Run Selection/Line in Python REPL contains config.python.REPL.sendToNativeREPL which should not be there Jul 3, 2024
@anthonykim1
Copy link

Hey @hanqi-monarch Thanks for filing this and apologies for late response here.

My issue is with config.python.REPL.sendToNativeREPL
By default it is false.

Since this is currently an experimental feature, the default value will depend on whether you are on a control vs. experiment group.

I am testing smartsend using multiline string below. If smart send works, i can place my cursor on both 1st and 2nd line of string and it should print properly. This only worked when I delete config.python.REPL.sendToNativeREPL from the when expression, AND uncheck Python: REPL: Send to Native REPL.

Okay, looks like you are missing smart send, good news is that that is now supported: #23521 So please give the latest version a try :)

If i place the cursor on return line and do shift+enter i get SyntaxError: 'return' outside function. I expected it to work.
If i place the cursor on def add line, it does load the function properly.

We use Python stand library module AST to find the nearest executable command, so since return itself is a whole top-level AST element such as like classes, etc, that is why running return will send itself rather than the whole class. This is bit different from sending whole dictionary when you are inside the multi-line dictionary. I do realize its bit strange at first too.
Maybe you could file a different issue can be filed in regards to better improving smart send? (specifically when it comes to sending code code with return where you have your cursor placed on your return statement).

Thanks.

@anthonykim1 anthonykim1 added area-repl and removed triage-needed Needs assignment to the proper sub-team labels Dec 13, 2024
@github-actions github-actions bot added the info-needed Issue requires more information from poster label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-repl info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants