Steps to reproduce:
1. Set locale to zh_CN.UTF-8
2. Open vim and edit a file with only characters in ascii range
file encoding set to utf-8 (or empty, with utf-8 being the default)
file encoding set to euc-cn
My vimscript is rusty, but I believe the issue is caused by the if-block here:
In my case, locale is zh_CN.UTF-8, which causes fileencodings option to be overridden with gb2312. After the if statements a few lines down, the final file encodings list ends up being:
Personally I haven't run into gb2312 for a very long time, I think for a utf-8 locale, it's safe to drop. Even if we think it's worth keeping, utf-8 should come first in the list.
Installed package versions:
Any chance you could give a rough patch?
Depends on how we want to proceed, I see a few options:
1. Explicitly check for UTF-8 locales and skip setting file encodings
2. Keep the gb2312 encoding, but have UTF-8 come first in the list
3. Remove all code that touches file encodings and use vim default, which is quite reasonable for 2021. Users who really care can set file encodings in their own vimrc.
3 is the most risky, but IMHO it's the cleanest, and the least surprising from a new Gentoo user perspective. I'm a recent migrant to Gentoo, and it certainly took me a while to figure out why/how my encodings are getting changed.
I'll leave it up to the maintainers to decide which option to choose, as I don't presume to know the full intent behind these lines of code. Happy to provide a patch.
In any case, the fix will end up breaking the existing behavior for some users, how does the Gentoo community handle such changes?