aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2015-06-23 20:48:17 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2016-11-05 14:49:23 +0100
commit4804001aff408558b8dd60ae3ba4cd9b84a5b949 (patch)
tree19905820144a9d1a9eff0b58df3f389209a5f237 /src
parent32d9c19e294f38a6adae6e055fc606fc3fd33f2f (diff)
downloadrneovim-4804001aff408558b8dd60ae3ba4cd9b84a5b949.tar.gz
rneovim-4804001aff408558b8dd60ae3ba4cd9b84a5b949.tar.bz2
rneovim-4804001aff408558b8dd60ae3ba4cd9b84a5b949.zip
encoding: only allow encoding=utf-8
Diffstat (limited to 'src')
-rw-r--r--src/nvim/option.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index a255165e32..cde740daf1 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -783,12 +783,6 @@ void set_init_1(void)
// Initialize multibyte (utf-8) handling
mb_init();
- // Don't change &encoding when resetting to defaults with ":set all&".
- opt_idx = findoption((char_u *)"encoding");
- if (opt_idx >= 0) {
- options[opt_idx].flags |= P_NODEFAULT;
- }
-
/* Set the default for 'helplang'. */
set_helplang_default(get_mess_lang());
}
@@ -2580,19 +2574,17 @@ did_set_string_option (
errmsg = e_invarg;
/* 'encoding' and 'fileencoding' */
} else if (varp == &p_enc || gvarp == &p_fenc) {
- if (varp == &p_enc && did_source_startup_scripts) {
- errmsg = e_afterinit;
- } else if (gvarp == &p_fenc) {
- if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL)
+ if (gvarp == &p_fenc) {
+ if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL) {
errmsg = e_modifiable;
- else if (vim_strchr(*varp, ',') != NULL)
- /* No comma allowed in 'fileencoding'; catches confusing it
- * with 'fileencodings'. */
+ } else if (vim_strchr(*varp, ',') != NULL) {
+ // No comma allowed in 'fileencoding'; catches confusing it
+ // with 'fileencodings'.
errmsg = e_invarg;
- else {
- /* May show a "+" in the title now. */
+ } else {
+ // May show a "+" in the title now.
redraw_titles();
- /* Add 'fileencoding' to the swap file. */
+ // Add 'fileencoding' to the swap file.
ml_setflags(curbuf);
}
}
@@ -2603,17 +2595,12 @@ did_set_string_option (
xfree(*varp);
*varp = p;
if (varp == &p_enc) {
- errmsg = mb_init();
- redraw_titles();
+ // only encoding=utf-8 allowed
+ if (STRCMP(p_enc, "utf-8") != 0) {
+ errmsg = e_invarg;
+ }
}
}
-
- if (errmsg == NULL) {
- /* When 'keymap' is used and 'encoding' changes, reload the keymap
- * (with another encoding). */
- if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
- (void)keymap_init();
- }
} else if (varp == &p_penc) {
/* Canonize printencoding if VIM standard one */
p = enc_canonize(p_penc);