editorconfig-vim
editorconfig-vim copied to clipboard
Stop changing 'encoding'
Changing 'encoding' has many side effects and that should be avoided. Strip BOM manually.
Fix #144 Fix #145 Fix #147
Would you be willing to add some test cases of files with different encodings?
Do we need to add some test cases with a .editorconfig
file with UTF-8 BOM? Then, should https://github.com/editorconfig/editorconfig-plugin-tests be updated?
Would you be willing to add some test cases of files with different encodings?
Do we need to add some test cases with a
.editorconfig
file with UTF-8 BOM? Then, should https://github.com/editorconfig/editorconfig-plugin-tests be updated?
@k-takata Good question! I don't think we need to update the main plugin tests, since this problem is specific to this plugin. If you or @h3xx can send me some test cases, I'll figure out where to put them.
How about creating a copy of https://github.com/editorconfig/editorconfig-plugin-tests/tree/master/test_files with just adding a UTF-8 BOM to test_files/.editorconfig
?
+1 for this PR. Tested these changes against the issue in my PR #194, and it in fact fixes the issue I described.
This PR seems more comprehensive than my change so I closed #194.
Summary of issue from #194 (~12 lines)
For some reason, this plugin is causing
:e
to change the file's encoding option (&fileencoding
) to utf-8, overriding whatever it's currently set to. This doesn't happen upon first opening the file, but only upon re-opening it with:e
.Steps to reproduce:
- Open and save a file in latin1 mode:
export LANG=en_US LC_ALL=en_US LC_CTYPE=en_US vim foo.txt :set fenc=latin1 :w
- Without closing Vim, reload the file:
:e
- Check the file encoding hasn't changed:
:echo &fenc
&fenc
should still belatin1
. If it was reset toutf-8
the issue persists.
This will also fix https://github.com/editorconfig/editorconfig-vim/issues/196
Merged --- let me know if you experience any issues!