-
Notifications
You must be signed in to change notification settings - Fork 510
When we paste powershell script in VS code, space is getting replaced by  #1628
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
Comments
Thanks for opening an issue @BipulRaman. This is quite similar to #1308. Please have a read of that. This is an encoding problem and you will need to ensure that your PowerShell and ISE encoding settings in the VM and host sessions, along with the VSCode encoding settings, are all synchronised. On Windows, it's likely you are using either the CP-1252 codepage or UTF-16 but VSCode is using UTF-8. This page is quite helpful for debugging the problem. Unfortunately, there is nothing we can do from the extension to work out what encoding bytes are coming from or going to; even if we could control copying and pasting (those things are in VSCode, not the PowerShell extension), trying to guess encodings and transforming inputs would break a lot more than it would fix. People trying to guess and transform encodings is part of the cause of this problem in the first place. |
If you look at the debug page I linked above, it looks like there might be a non-breaking space hidden in your script. The best way to debug this is going to be:
My general advice in these cross-encoding scenarios is to stick to ASCII characters only. Strip out any bytes above 0x7f in the script file. |
@BipulRaman did you manage to find a fix for this issue? Have a look through the issues in this repo for encoding. This one might help: #1306 (comment). |
Also #1351 |
Issue Type: Bug
Step1: Copy a woking powershell script
Step2: When we paste powershell script in VS code, space is getting replaced by Â
Note: It is not visible in editor, but during run, error is being thrown as syntex error. This issue is observed specially code is copied from a ps1 file which is copied from one VM to another by putting into ZIP file. This issue is not observed when we paste it in Powershell ISE. I am sharing the sample script here:
https://gist.github.com/BipulRaman/eb598cfaa75d9b077f0e18ba021346a5
 will not be visible in the editor, but when you will run the script, you will see exception. I am not able to reproduce the issue repeatedly, but i have captured screenshot for the same code in two different editor. Please have a look on attached screenshots.


VS Code version: Code 1.29.1 (bc24f98b5f70467bc689abf41cc5550ca637088e, 2018-11-15T19:13:36.375Z)
OS version: Windows_NT x64 10.0.17763
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Extensions (10)
The text was updated successfully, but these errors were encountered: