microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.33k stars 1.19k forks source link

Missing first character for execute selection #24296

Open tttienthinh opened 3 weeks ago

tttienthinh commented 3 weeks ago

Type: Bug

Behaviour

KeyboardInterrupt
>>> mport pandas as pd

Instead of

KeyboardInterrupt
>>> import pandas as pd

while selecting "import pandas as pd" and doing SHIFT + Enter

Steps to reproduce:

  1. Install the Python Extension on VS Code (v2024.16.0 or v2024.16.0)
  2. Create a Python file (.py)
  3. Write some python code "import pandas as pd"
  4. Select it and run it with Shift + Enter
  5. You get "mport pandas as pd" in the terminal

Diagnostic data

To solve the problem, downgrade to (v2024.14.1 or under) by : Going to Extension > Right click on Python extension > "Install Specific Version > 2024.14.1 > Restart extension

Extension version: 2024.16.1 VS Code version: Code 1.94.2 (384ff7382de624fb94dbaf6da11977bba1ecd427, 2024-10-09T16:08:44.566Z) OS version: Windows_NT x64 10.0.22631 Modes:

User Settings

``` languageServer: "Pylance" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |JavaScript Debugger|ms-vscode.js-debug|1.94.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.3| |Pylance|ms-python.vscode-pylance|2024.10.1| |Python|ms-python.python|2024.16.1| |Python Debugger|ms-python.debugpy|2024.10.0| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.10|
System Info |Item|Value| |---|---| |CPUs|13th Gen Intel(R) Core(TM) i7-1360P (16 x 2611)| |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
webnn: disabled_off| |Load (avg)|undefined| |Memory (System)|15.65GB (6.30GB free)| |Process Argv|--crash-reporter-id d4f94bd2-b3d0-476a-a8e2-4ee326151f29| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 2i9eh265:30646982 962ge761:30959799 pythongtdpath:30769146 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30995554 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 jg8ic977:31013176 a69g1124:31058053 dvdeprecation:31068756 dwnewjupytercf:31046870 impr_priority:31102340 nativerepl1:31139838 refactort:31108082 pythonrstrctxt:31112756 wkspc-onlycs-t:31132770 wkspc-ranged-t:31151552 cf971741:31144450 autoexpandse:31146404 iacca2:31156134 notype1:31157159 5fd0e150:31155592 ```
anthonykim1 commented 3 weeks ago

are you executing after you have explicitly highlighted the code you are sending or just shift+entering on the line without any highlights?

tttienthinh commented 3 weeks ago

Hi Anthony,

Thank you for your answer. I have tried both highlighting the code and just being on the line. Both ends up with a missing character.

On Mon, Oct 14, 2024, 16:42 Anthony Kim @.***> wrote:

are you executing after you have explicitly highlighted the code you are sending or just shift+entering on the line without any highlights?

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-python/issues/24296#issuecomment-2411633742, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIL642RF2HMGDHGG6GIDTF3Z3PQ7RAVCNFSM6AAAAABP3VKOKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJRGYZTGNZUGI . You are receiving this because you authored the thread.Message ID: @.***>

karthiknadig commented 3 weeks ago

@tttienthinh Are you using powershell, cmd, or any other terminal shell?

tttienthinh commented 3 weeks ago

I am using the PowerShell Terminal of VS Code I guess. This is what I get when I Shift+Enter for the first time :

PS C:\Users\...> & "C:/Program Files/Python312/python.exe"
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.