aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/options.lua69
-rw-r--r--src/nvim/optionstr.c210
-rw-r--r--test/old/testdir/test_options.vim81
3 files changed, 279 insertions, 81 deletions
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index e15ed64b24..364152ff01 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -196,7 +196,8 @@ return {
type='string', list='comma', scope={'global'},
deny_duplicates=true,
varname='p_bo',
- defaults={if_true="all"}
+ defaults={if_true="all"},
+ cb='did_set_belloff'
},
{
full_name='binary', abbreviation='bin',
@@ -256,7 +257,8 @@ return {
noglob=true,
alloced=true,
varname='p_bh',
- defaults={if_true=""}
+ defaults={if_true=""},
+ cb='did_set_bufhidden'
},
{
full_name='buflisted', abbreviation='bl',
@@ -283,7 +285,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_cmp',
- defaults={if_true="internal,keepascii"}
+ defaults={if_true="internal,keepascii"},
+ cb='did_set_casemap'
},
{
full_name='cdhome', abbreviation='cdh',
@@ -378,7 +381,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_cb',
- defaults={if_true=""}
+ defaults={if_true=""},
+ cb='did_set_clipboard'
},
{
full_name='cmdheight', abbreviation='ch',
@@ -402,7 +406,8 @@ return {
type='string', list='onecomma', scope={'window'},
deny_duplicates=true,
redraw={'current_window'},
- defaults={if_true=""}
+ defaults={if_true=""},
+ cb='did_set_colorcolumn'
},
{
full_name='columns', abbreviation='co',
@@ -542,14 +547,16 @@ return {
type='string', list='onecomma', scope={'window'},
deny_duplicates=true,
redraw={'current_window_only'},
- defaults={if_true="both"}
+ defaults={if_true="both"},
+ cb='did_set_cursorlineopt'
},
{
full_name='debug',
short_desc=N_("to \"msg\" to see all error messages"),
type='string', scope={'global'},
varname='p_debug',
- defaults={if_true=""}
+ defaults={if_true=""},
+ cb='did_set_debug'
},
{
full_name='define', abbreviation='def',
@@ -638,7 +645,8 @@ return {
short_desc=N_("in which direction 'equalalways' works"),
type='string', scope={'global'},
varname='p_ead',
- defaults={if_true="both"}
+ defaults={if_true="both"},
+ cb='did_set_eadirection'
},
{
full_name='edcompatible', abbreviation='ed',
@@ -784,7 +792,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_ffs',
- defaults={if_true=macros('DFLT_FFS_VIM')}
+ defaults={if_true=macros('DFLT_FFS_VIM')},
+ cb='did_set_fileformats'
},
{
full_name='fileignorecase', abbreviation='fic',
@@ -834,7 +843,8 @@ return {
deny_duplicates=true,
redraw={'current_window'},
varname='p_fcl',
- defaults={if_true=""}
+ defaults={if_true=""},
+ cb='did_set_foldclose'
},
{
full_name='foldcolumn', abbreviation='fdc',
@@ -928,7 +938,8 @@ return {
deny_duplicates=true,
redraw={'curswant'},
varname='p_fdo',
- defaults={if_true="block,hor,mark,percent,quickfix,search,tag,undo"}
+ defaults={if_true="block,hor,mark,percent,quickfix,search,tag,undo"},
+ cb='did_set_foldopen'
},
{
full_name='foldtext', abbreviation='fdt',
@@ -1193,7 +1204,8 @@ return {
short_desc=N_("Live preview of substitution"),
type='string', scope={'global'},
varname='p_icm',
- defaults={if_true="nosplit"}
+ defaults={if_true="nosplit"},
+ cb='did_set_inccommand'
},
{
full_name='include', abbreviation='inc',
@@ -1308,7 +1320,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_jop',
- defaults={if_true=''}
+ defaults={if_true=''},
+ cb='did_set_jumpoptions'
},
{
full_name='keymap', abbreviation='kmp',
@@ -1632,7 +1645,8 @@ return {
short_desc=N_("changes meaning of mouse buttons"),
type='string', scope={'global'},
varname='p_mousem',
- defaults={if_true="popup_setpos"}
+ defaults={if_true="popup_setpos"},
+ cb='did_set_mousemodel'
},
{
full_name='mousemoveevent', abbreviation='mousemev',
@@ -1871,7 +1885,8 @@ return {
short_desc=N_("Changes the way redrawing works (debug)"),
type='string', list='onecomma', scope={'global'},
varname='p_rdb',
- defaults={if_true=''}
+ defaults={if_true=''},
+ cb='did_set_redrawdebug'
},
{
full_name='redrawtime', abbreviation='rdt',
@@ -2006,7 +2021,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_sbo',
- defaults={if_true="ver,jump"}
+ defaults={if_true="ver,jump"},
+ cb='did_set_scrollopt'
},
{
full_name='sections', abbreviation='sect',
@@ -2037,7 +2053,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_slm',
- defaults={if_true=""}
+ defaults={if_true=""},
+ cb='did_set_selectmode'
},
{
full_name='sessionoptions', abbreviation='ssop',
@@ -2203,7 +2220,8 @@ return {
short_desc=N_("change location of partial command"),
type='string', scope={'global'},
varname='p_sloc',
- defaults={if_true="last"}
+ defaults={if_true="last"},
+ cb='did_set_showcmdloc'
},
{
full_name='showfulltag', abbreviation='sft',
@@ -2362,7 +2380,8 @@ return {
short_desc=N_("determines scroll behavior for split windows"),
type='string', scope={'global'},
varname='p_spk',
- defaults={if_true='cursor'}
+ defaults={if_true='cursor'},
+ cb='did_set_splitkeep'
},
{
full_name='splitright', abbreviation='spr',
@@ -2432,7 +2451,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_swb',
- defaults={if_true="uselast"}
+ defaults={if_true="uselast"},
+ cb='did_set_switchbuf'
},
{
full_name='synmaxcol', abbreviation='smc',
@@ -2559,7 +2579,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_tpf',
- defaults={if_true="BS,HT,ESC,DEL"}
+ defaults={if_true="BS,HT,ESC,DEL"},
+ cb='did_set_termpastefilter'
},
{
full_name='terse',
@@ -2774,7 +2795,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_vop',
- defaults={if_true="folds,cursor,curdir"}
+ defaults={if_true="folds,cursor,curdir"},
+ cb='did_set_viewoptions'
},
{
-- Alias for "shada".
@@ -2870,7 +2892,8 @@ return {
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_wop',
- defaults={if_true='pum,tagfile'}
+ defaults={if_true='pum,tagfile'},
+ cb='did_set_wildoptions'
},
{
full_name='winaltkeys', abbreviation='wak',
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index d7cf948730..9c173f5c2c 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -698,6 +698,18 @@ const char *did_set_backupext_or_patchmode(optset_T *args FUNC_ATTR_UNUSED)
return NULL;
}
+/// The 'belloff' option is changed.
+const char *did_set_belloff(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_bo, p_bo_values, &bo_flags, true);
+}
+
+/// The 'termpastefilter' option is changed.
+const char *did_set_termpastefilter(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_tpf, p_tpf_values, &tpf_flags, true);
+}
+
/// The 'breakindentopt' option is changed.
const char *did_set_breakindentopt(optset_T *args)
{
@@ -740,11 +752,15 @@ const char *did_set_helpfile(optset_T *args FUNC_ATTR_UNUSED)
}
/// The 'cursorlineopt' option is changed.
-static void did_set_cursorlineopt(win_T *win, char **varp, const char **errmsg)
+const char *did_set_cursorlineopt(optset_T *args)
{
- if (**varp == NUL || fill_culopt_flags(*varp, win) != OK) {
- *errmsg = e_invarg;
+ win_T *win = (win_T *)args->os_win;
+
+ if (*args->os_varp == NUL || fill_culopt_flags(args->os_varp, win) != OK) {
+ return e_invarg;
}
+
+ return NULL;
}
/// The 'helplang' option is changed.
@@ -771,17 +787,29 @@ const char *did_set_highlight(optset_T *args)
return NULL;
}
-static void did_set_opt_flags(char *val, char **values, unsigned *flagp, bool list,
- const char **errmsg)
+static const char *did_set_opt_flags(char *val, char **values, unsigned *flagp, bool list)
{
if (opt_strings_flags(val, values, flagp, list) != OK) {
- *errmsg = e_invarg;
+ return e_invarg;
}
+ return NULL;
+}
+
+static const char *did_set_opt_strings(char *val, char **values, bool list)
+{
+ return did_set_opt_flags(val, values, NULL, list);
+}
+
+/// The 'selectmode' option is changed.
+const char *did_set_selectmode(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_slm, p_slm_values, true);
}
-static void did_set_opt_strings(char *val, char **values, bool list, const char **errmsg)
+/// The 'inccommand' option is changed.
+const char *did_set_inccommand(optset_T *args FUNC_ATTR_UNUSED)
{
- did_set_opt_flags(val, values, NULL, list, errmsg);
+ return did_set_opt_strings(p_icm, p_icm_values, false);
}
/// The 'sessionoptions' option is changed.
@@ -832,6 +860,18 @@ const char *did_set_background(optset_T *args FUNC_ATTR_UNUSED)
return NULL;
}
+/// The 'clipboard' option is changed.
+const char *did_set_clipboard(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_cb, p_cb_values, &cb_flags, true);
+}
+
+/// The 'foldopen' option is changed.
+const char *did_set_foldopen(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, true);
+}
+
/// The 'wildmode' option is changed.
const char *did_set_wildmode(optset_T *args FUNC_ATTR_UNUSED)
{
@@ -859,6 +899,12 @@ const char *did_set_eventignore(optset_T *args FUNC_ATTR_UNUSED)
return NULL;
}
+/// The 'eadirection' option is changed.
+const char *did_set_eadirection(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_ead, p_ead_values, false);
+}
+
// 'encoding', 'fileencoding' and 'makeencoding'
static void did_set_encoding(buf_T *buf, char **varp, char **gvarp, int opt_flags,
const char **errmsg)
@@ -965,6 +1011,12 @@ const char *did_set_fileformat(optset_T *args)
return NULL;
}
+/// The 'fileformats' option is changed.
+const char *did_set_fileformats(optset_T *args)
+{
+ return did_set_opt_strings(p_ffs, p_ff_values, true);
+}
+
/// The 'matchpairs' option is changed.
const char *did_set_matchpairs(optset_T *args)
{
@@ -999,6 +1051,13 @@ const char *did_set_cinoptions(optset_T *args FUNC_ATTR_UNUSED)
return NULL;
}
+/// The 'colorcolumn' option is changed.
+const char *did_set_colorcolumn(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ return check_colorcolumn(win);
+}
+
static void did_set_comments(char **varp, char *errbuf, size_t errbuflen, const char **errmsg)
{
for (char *s = *varp; *s;) {
@@ -1064,6 +1123,12 @@ const char *did_set_verbosefile(optset_T *args)
return NULL;
}
+/// The 'viewoptions' option is changed.
+const char *did_set_viewoptions(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, true);
+}
+
static int shada_idx = -1;
static const char *did_set_shada(vimoption_T **opt, int *opt_idx, bool *free_oldval, char *errbuf,
@@ -1241,7 +1306,13 @@ const char *did_set_spellsuggest(optset_T *args FUNC_ATTR_UNUSED)
return NULL;
}
- /// The 'mkspellmem' option is changed.
+/// The 'splitkeep' option is changed.
+const char *did_set_splitkeep(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_spk, p_spk_values, false);
+}
+
+/// The 'mkspellmem' option is changed.
const char *did_set_mkspellmem(optset_T *args FUNC_ATTR_UNUSED)
{
if (spell_check_msm() != OK) {
@@ -1250,6 +1321,19 @@ const char *did_set_mkspellmem(optset_T *args FUNC_ATTR_UNUSED)
return NULL;
}
+/// The 'mousemodel' option is changed.
+const char *did_set_mousemodel(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_mousem, p_mousem_values, false);
+}
+
+/// The 'bufhidden' option is changed.
+const char *did_set_bufhidden(optset_T *args)
+{
+ buf_T *buf = (buf_T *)args->os_buf;
+ return did_set_opt_strings(buf->b_p_bh, p_bufhidden_values, false);
+}
+
/// The 'buftype' option is changed.
const char *did_set_buftype(optset_T *args)
{
@@ -1270,6 +1354,12 @@ const char *did_set_buftype(optset_T *args)
return NULL;
}
+/// The 'casemap' option is changed.
+const char *did_set_casemap(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, true);
+}
+
/// The 'statusline', 'winbar', 'tabline', 'rulerformat' or 'statuscolumn' option is changed.
///
/// @param rulerformat true if the 'rulerformat' option is changed
@@ -1338,6 +1428,12 @@ const char *did_set_statuscolumn(optset_T *args)
return did_set_statustabline_rulerformat(args, false, true);
}
+/// The 'scrollopt' option is changed.
+const char *did_set_scrollopt(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_sbo, p_scbopt_values, true);
+}
+
static void did_set_complete(char **varp, char *errbuf, size_t errbuflen, const char **errmsg)
{
// check if it is a valid value for 'complete' -- Acevedo
@@ -1399,6 +1495,12 @@ const char *did_set_completeslash(optset_T *args)
}
#endif
+/// The 'showcmdloc' option is changed.
+const char *did_set_showcmdloc(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_sloc, p_sloc_values, true);
+}
+
/// The 'signcolumn' option is changed.
const char *did_set_signcolumn(optset_T *args)
{
@@ -1439,6 +1541,12 @@ const char *did_set_backspace(optset_T *args FUNC_ATTR_UNUSED)
return NULL;
}
+/// The 'switchbuf' option is changed.
+const char *did_set_switchbuf(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_swb, p_swb_values, &swb_flags, true);
+}
+
/// The 'tagcase' option is changed.
const char *did_set_tagcase(optset_T *args)
{
@@ -1466,6 +1574,12 @@ const char *did_set_tagcase(optset_T *args)
return NULL;
}
+/// The 'debug' option is changed.
+const char *did_set_debug(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_debug, p_debug_values, false);
+}
+
/// The 'diffopt' option is changed.
const char *did_set_diffopt(optset_T *args FUNC_ATTR_UNUSED)
{
@@ -1560,6 +1674,24 @@ const char *did_set_virtualedit(optset_T *args)
return NULL;
}
+/// The 'jumpoptions' option is changed.
+const char *did_set_jumpoptions(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_jop, p_jop_values, &jop_flags, true);
+}
+
+/// The 'redrawdebug' option is changed.
+const char *did_set_redrawdebug(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_rdb, p_rdb_values, &rdb_flags, true);
+}
+
+/// The 'wildoptions' option is changed.
+const char *did_set_wildoptions(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_wop, p_wop_values, &wop_flags, true);
+}
+
/// The 'lispoptions' option is changed.
const char *did_set_lispoptions(optset_T *args)
{
@@ -1657,6 +1789,12 @@ const char *did_set_vartabstop(optset_T *args)
return NULL;
}
+/// The 'nrformats' option is changed.
+const char *did_set_nrformats(optset_T *args)
+{
+ return did_set_opt_strings(args->os_varp, p_nf_values, true);
+}
+
static void did_set_optexpr(char **varp)
{
char *name = get_scriptlocal_funcname(*varp);
@@ -1666,6 +1804,12 @@ static void did_set_optexpr(char **varp)
}
}
+/// The 'foldclose' option is changed.
+const char *did_set_foldclose(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_fcl, p_fcl_values, true);
+}
+
// handle option that is a list of flags.
static void did_set_option_listflag(char **varp, char *flags, char *errbuf, size_t errbuflen,
const char **errmsg)
@@ -1776,30 +1920,12 @@ static const char *did_set_string_option_for(buf_T *buf, win_T *win, int opt_idx
|| varp == &p_isp // 'isprint'
|| varp == &p_isf) { // 'isfname'
did_set_isopt(buf, &did_chartab, &errmsg);
- } else if (gvarp == &win->w_allbuf_opt.wo_culopt) { // 'cursorlineopt'
- did_set_cursorlineopt(win, varp, &errmsg);
- } else if (varp == &win->w_p_cc) { // 'colorcolumn'
- errmsg = check_colorcolumn(win);
- } else if (varp == &p_jop) { // 'jumpoptions'
- did_set_opt_flags(p_jop, p_jop_values, &jop_flags, true, &errmsg);
- } else if (gvarp == &p_nf) { // 'nrformats'
- did_set_opt_strings(*varp, p_nf_values, true, &errmsg);
- } else if (varp == &p_vop) { // 'viewoptions'
- did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, true, &errmsg);
- } else if (varp == &p_rdb) { // 'redrawdebug'
- did_set_opt_flags(p_rdb, p_rdb_values, &rdb_flags, true, &errmsg);
- } else if (varp == &p_sbo) { // 'scrollopt'
- did_set_opt_strings(p_sbo, p_scbopt_values, true, &errmsg);
- } else if (varp == &p_wop) { // 'wildoptions'
- did_set_opt_flags(p_wop, p_wop_values, &wop_flags, true, &errmsg);
} else if (varp == &p_enc // 'encoding'
|| gvarp == &p_fenc // 'fileencoding'
|| gvarp == &p_menc) { // 'makeencoding'
did_set_encoding(buf, varp, gvarp, opt_flags, &errmsg);
} else if (varp == &buf->b_p_keymap) { // 'keymap'
did_set_keymap(buf, varp, opt_flags, value_checked, &errmsg);
- } else if (varp == &p_ffs) { // 'fileformats'
- did_set_opt_strings(p_ffs, p_ff_values, true, &errmsg);
} else if (gvarp == &p_com) { // 'comments'
did_set_comments(varp, errbuf, errbuflen, &errmsg);
} else if (varp == &p_lcs // global 'listchars'
@@ -1811,41 +1937,11 @@ static const char *did_set_string_option_for(buf_T *buf, win_T *win, int opt_idx
errmsg = set_chars_option(win, varp, true);
} else if (varp == &p_shada) { // 'shada'
errmsg = did_set_shada(&opt, &opt_idx, &free_oldval, errbuf, errbuflen);
- } else if (varp == &p_slm) { // 'selectmode'
- did_set_opt_strings(p_slm, p_slm_values, true, &errmsg);
- } else if (varp == &p_mousem) { // 'mousemodel'
- did_set_opt_strings(p_mousem, p_mousem_values, false, &errmsg);
- } else if (varp == &p_swb) { // 'switchbuf'
- did_set_opt_flags(p_swb, p_swb_values, &swb_flags, true, &errmsg);
- } else if (varp == &p_spk) { // 'splitkeep'
- did_set_opt_strings(p_spk, p_spk_values, false, &errmsg);
- } else if (varp == &p_debug) { // 'debug'
- did_set_opt_strings(p_debug, p_debug_values, true, &errmsg);
- } else if (varp == &p_ead) { // 'eadirection'
- did_set_opt_strings(p_ead, p_ead_values, false, &errmsg);
- } else if (varp == &p_cb) { // 'clipboard'
- did_set_opt_flags(p_cb, p_cb_values, &cb_flags, true, &errmsg);
- } else if (gvarp == &p_bh) { // 'bufhidden'
- did_set_opt_strings(buf->b_p_bh, p_bufhidden_values, false, &errmsg);
} else if (gvarp == &p_cpt) { // 'complete'
did_set_complete(varp, errbuf, errbuflen, &errmsg);
- } else if (varp == &p_sloc) { // 'showcmdloc'
- did_set_opt_strings(*varp, p_sloc_values, false, &errmsg);
- } else if (varp == &p_bo) {
- did_set_opt_flags(p_bo, p_bo_values, &bo_flags, true, &errmsg);
- } else if (varp == &p_cmp) { // 'casemap'
- did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, true, &errmsg);
- } else if (varp == &p_fdo) { // 'foldopen'
- did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, true, &errmsg);
- } else if (varp == &p_fcl) { // 'foldclose'
- did_set_opt_strings(*varp, p_fcl_values, true, &errmsg);
- } else if (varp == &p_icm) { // 'inccommand'
- did_set_opt_strings(*varp, p_icm_values, false, &errmsg);
} else if (gvarp == &p_ft // 'filetype'
|| gvarp == &p_syn) { // 'syntax'
did_set_filetype_or_syntax(varp, oldval, value_checked, &value_changed, &errmsg);
- } else if (varp == &p_tpf) {
- did_set_opt_flags(p_tpf, p_tpf_values, &tpf_flags, true, &errmsg);
} else if (varp == &p_dex // 'diffexpr'
|| gvarp == &win->w_allbuf_opt.wo_fde // 'foldexpr'
|| gvarp == &win->w_allbuf_opt.wo_fdt // 'foldtext'
diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim
index d18802adc1..8a3a022748 100644
--- a/test/old/testdir/test_options.vim
+++ b/test/old/testdir/test_options.vim
@@ -396,7 +396,16 @@ func Test_set_errors()
if has('mouseshape')
call assert_fails('se mouseshape=i-r:x', 'E547:')
endif
- call assert_fails('set backupext=~ patchmode=~', 'E589:')
+
+ " Test for 'backupext' and 'patchmode' set to the same value
+ set backupext=.bak
+ set patchmode=.patch
+ call assert_fails('set patchmode=.bak', 'E589:')
+ call assert_equal('.patch', &patchmode)
+ call assert_fails('set backupext=.patch', 'E589:')
+ call assert_equal('.bak', &backupext)
+ set backupext& patchmode&
+
call assert_fails('set winminheight=10 winheight=9', 'E591:')
call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
call assert_fails("set showbreak=\x01", 'E595:')
@@ -1344,4 +1353,74 @@ func Test_set_min_lines_columns()
let &columns = save_columns
endfunc
+" Test for reverting a string option value if the new value is invalid.
+func Test_string_option_revert_on_failure()
+ new
+ let optlist = [
+ \ ['ambiwidth', 'double', 'a123'],
+ \ ['background', 'dark', 'a123'],
+ \ ['backspace', 'eol', 'a123'],
+ \ ['backupcopy', 'no', 'a123'],
+ \ ['belloff', 'showmatch', 'a123'],
+ \ ['breakindentopt', 'min:10', 'list'],
+ \ ['bufhidden', 'wipe', 'a123'],
+ \ ['buftype', 'nowrite', 'a123'],
+ \ ['casemap', 'keepascii', 'a123'],
+ \ ['cedit', "\<C-Y>", 'z'],
+ \ ['colorcolumn', '10', 'z'],
+ \ ['commentstring', '#%s', 'a123'],
+ \ ['complete', '.,t', 'a'],
+ \ ['completefunc', 'MyCmplFunc', '1a-'],
+ "\ ['completeopt', 'popup', 'a123'],
+ \ ['completeopt', 'preview', 'a123'],
+ "\ ['completepopup', 'width:20', 'border'],
+ \ ['concealcursor', 'v', 'xyz'],
+ "\ ['cpoptions', 'HJ', '~'],
+ \ ['cpoptions', 'J', '~'],
+ "\ ['cryptmethod', 'zip', 'a123'],
+ \ ['cursorlineopt', 'screenline', 'a123'],
+ \ ['debug', 'throw', 'a123'],
+ \ ['diffopt', 'iwhite', 'a123'],
+ \ ['display', 'uhex', 'a123'],
+ \ ['eadirection', 'hor', 'a123'],
+ \ ['encoding', 'utf-8', 'a123'],
+ \ ['eventignore', 'TextYankPost', 'a123'],
+ \ ['fileencoding', 'utf-8', 'a123,'],
+ \ ['fileformat', 'mac', 'a123'],
+ \ ['fileformats', 'mac', 'a123'],
+ \ ['fillchars', 'diff:~', 'a123'],
+ \ ['foldclose', 'all', 'a123'],
+ \ ['foldmarker', '[[[,]]]', '[[['],
+ \ ['foldmethod', 'marker', 'a123'],
+ \ ['foldopen', 'percent', 'a123'],
+ \ ['formatoptions', 'an', '*'],
+ \ ['guicursor', 'n-v-c:block-Cursor/lCursor', 'n-v-c'],
+ \ ['helplang', 'en', 'a'],
+ "\ ['highlight', '!:CursorColumn', '8:']
+ \ ]
+ if has('gui')
+ call add(optlist, ['browsedir', 'buffer', 'a123'])
+ endif
+ if has('clipboard_working')
+ call add(optlist, ['clipboard', 'unnamed', 'a123'])
+ endif
+ if has('win32')
+ call add(optlist, ['completeslash', 'slash', 'a123'])
+ endif
+ if has('cscope')
+ call add(optlist, ['cscopequickfix', 't-', 'z-'])
+ endif
+ if !has('win32') && !has('nvim')
+ call add(optlist, ['imactivatefunc', 'MyCmplFunc', '1a-'])
+ endif
+ for opt in optlist
+ exe $"let save_opt = &{opt[0]}"
+ exe $"let &{opt[0]} = '{opt[1]}'"
+ call assert_fails($"let &{opt[0]} = '{opt[2]}'", '', opt[0])
+ call assert_equal(opt[1], eval($"&{opt[0]}"), opt[0])
+ exe $"let &{opt[0]} = save_opt"
+ endfor
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab