GitDiffMargin
GitDiffMargin copied to clipboard
Opening file changes its encoding
Any file that I open with Visual Studio 2017 changes encoding from UTF-8 to us-ascii. I can confirm this in versions 15.3.3+. Looks like this
Before opening:
> file -b source.cs
text/plain; charset=utf-8
After opening:
> file -b source.cs
text/plain; charset=us-ascii
Immediately after opening the margin indicates that entire file has changed even though git correctly recognizes changed lines. Git does however show the BOM character as being added. Confusing and annoying.
I though this was solely related to #127 but it's more complex. True enough, when I installed 3.5.0 the file's encoding doesn't change but still the entire margin is in blue...
@tpluscode Do you know about Fix File Encoding
When you edit a UTF-8 file in Visual Studio, it adds the byte order mark (BOM) sequence to the beginning of the file. You can select an encoding manually, but you need to do it each time you reopen the file.
I though this was solely related to #127 but it's more complex
I can't imagine this can be related because this is used only when you do a diff in the diff window!
True enough, when I installed 3.5.0 the file's encoding doesn't change but still the entire margin is in blue...
Might be due to Visual Studio which add the BOM
Could you please try to uninstall GitDiffMargin and do the test with the file to see if the encoding is changed, because I can't imagine that GitDiffMargin change the encoding!
Thanks for reporting this!
Okay now I'm confused. I thought I'd nailed it yesterday but now whichever version I try it seems to work fine 😥.
However, it still highlights the entire margin as modified even though neither VS nor git detects any changes.
It is really GitDiffMargin displayed and not Visual Studio Track Changes ?
Yes, definitely Git Diff Margin. Click it and entire file appears in the pop-up
@tpluscode Open the folder containing the file that was giving you problems. Then work your way from there to the root of the drive, looking in each folder for a file called .editorconfig. When you find it, look in that file for any lines starting with charset. Let me know if you find any (and if it applies to the source file, what its value is).
Visual Studio 15.3 added support for this property. It shouldn't apply by simply opening a file, but it definitely will apply when you click save.
Thanks @sharwell for this suggestion. I don't use .editorconfig and there is no anywhere up the tree. Not sure where it would've come from.
But, maybe I can actually create one to enforce expected behaviour?
@tpluscode Do you use ReSharper?
I do. Anything in particular I should look for?
@tpluscode Maybe you should look at File Formatting Info window which would display if any editorconfig or others are modifying your file.
