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
{{ message }}
Repository navigation
Git: "Stage selected ranges" command changes encoding to UTF-8 #36219
Create file with non UTF-8 (UTF-8 with BOM for example) encoding
Commit it
Make some changes
Open VScode's diff view
Select some range and run command "Git: Stage Selected Ranges"
Check encoding of the staged file
Expected result: initial encoding preserved
Actual result: encoding is set to UTF-8
Reproduces without extensions: Yes
Note: "files.encoding" and "files.autoGuessEncoding" settings of VScode doesn't affect anyhow on the result.
Reacted by Andrey, Aaron Simmonds, Christian Gullin, Sharon (Sean) Rolel, Gokul Shanth Raveendran, userFromHades, Bruno Gautier, Sébastien Watteau, Jon Carrier, Petr Šolín and 6 more
I have the same problem on VSCode Version: 1.18.0 - Insider, OS Version: Windows 10 and this problem also reproduces without extentions. As the my project requires only one file encoding, that's very uncomfortable for me to stage and commit file ranges using external programs like source tree.
Please take a look on this problem
created a file with encoding "UTF8 With Bom", within my repo.
committed this file
using vs code, edited this file
under the "Source Control" tab, I selected this file
ran the command "Git: Stage Selected Ranges"
under the "Source Control" tab, Under the "Staged Changes" section, I select my file.
After this, I am unsure where to look for encoding of the file.
At the bottom-right of the vs code window, I see "Line 1, Col 1 Spaces: 4 Plain Text". But no mention of encoding.
Are there any news about this? I am working on a Windows-1252 file and using "Stage Selected Ranges" tries to read it UTF-8 (using git add --patch works correctly)
changed the title [-]"Stage selected ranges" command changes encoding to UTF-8 (without regarding to the initial file encoding)[/-][+]Git: "Stage selected ranges" command changes encoding to UTF-8[/+]on Sep 18, 2018
I'm looking at this right now, it seems that is because it creates a new document to receive the changes, and the new document doen't refer to any encoding.
I'll need to find how to find the encoding from the current opened document to use the same to the newly created document.
Unfortunately Stage Selected Ranges is unusable because of this problem. Our files are in UTF-8-BOM format and Stage Selected Ranges command strips BOM.
child.stdin.end() is always called with 'utf8', regardless of original file encoding.
Object is staged using git.exe hash-object --stdin -w --path test.cpp
João Moreno (@joaomoreno) can you please give me some hint how to continue? Is original file encoding (including BOM/non-BOM information) available here? Thank you. I would really like to fix this problem, so we can use VSCode for interactive staging.
Reacted by Andrey, Petr Šolín, Alieh S, thoemy, KUGA2, Patrick-Ze and Rafael Gomes
This is an annoying issue, because when you go to view the changes on GitHub, it appears as if the entire file was modified, so you can't see what exactly changed. I'll have to keep using git add -p until this is fixed.
Activity
harimambura commentedon Nov 8, 2017
I have the same problem on VSCode Version: 1.18.0 - Insider, OS Version: Windows 10 and this problem also reproduces without extentions. As the my project requires only one file encoding, that's very uncomfortable for me to stage and commit file ranges using external programs like source tree.
Please take a look on this problem
amitdey1987 commentedon Feb 8, 2018
if this bug is up for grabs, can I take this up?
amitdey1987 commentedon Feb 9, 2018
As Artyom Koval (@kav137) describes, how can I"Check encoding of the staged file"?
These are the steps I performed
After this, I am unsure where to look for encoding of the file.
At the bottom-right of the vs code window, I see "Line 1, Col 1 Spaces: 4 Plain Text". But no mention of encoding.
harimambura commentedon Feb 9, 2018
Amit Dey (@amitdey1987)
I recorded the video which shows how you can reproduce this issue
https://youtu.be/t-ZLTPcUISs
lorenzo-arena commentedon May 17, 2018
Are there any news about this? I am working on a Windows-1252 file and using "Stage Selected Ranges" tries to read it UTF-8 (using
git add --patchworks correctly)userFromHades commentedon Sep 18, 2018
1.27.2 it looks like it's still broken.
[-]"Stage selected ranges" command changes encoding to UTF-8 (without regarding to the initial file encoding)[/-][+]Git: "Stage selected ranges" command changes encoding to UTF-8[/+]felipecaputo commentedon Oct 29, 2018
I'm looking at this right now, it seems that is because it creates a new document to receive the changes, and the new document doen't refer to any encoding.
I'll need to find how to find the encoding from the current opened document to use the same to the newly created document.
As soon as I find something, I'll let you know
rysavyjan commentedon Apr 24, 2019
Unfortunately Stage Selected Ranges is unusable because of this problem. Our files are in UTF-8-BOM format and Stage Selected Ranges command strips BOM.
Are we waiting for #55110?
rysavyjan commentedon May 16, 2019
So I installed OSS Dev version of VSCode and fired debugger. The problem is in vscode\extensions\git\src\git.ts
child.stdin.end() is always called with 'utf8', regardless of original file encoding.
Object is staged using
git.exe hash-object --stdin -w --path test.cppJoão Moreno (@joaomoreno) can you please give me some hint how to continue? Is original file encoding (including BOM/non-BOM information) available here? Thank you. I would really like to fix this problem, so we can use VSCode for interactive staging.
KUGA2 commentedon Jul 30, 2019
Problem is still occurring in 1.36.1.
rysavyjan: can we just omit the encoding in this call?
rafaelgomesxyz commentedon Sep 29, 2019
This is an annoying issue, because when you go to view the changes on GitHub, it appears as if the entire file was modified, so you can't see what exactly changed. I'll have to keep using
git add -puntil this is fixed.joaomoreno commentedon Nov 20, 2019
This has been fixed thanks to #55110
Verification:
Current stable (broken):
Fixed: