mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 18:28:19 +00:00
vim-patch:7.4.786
Problem: It is not possible for a plugin to adjust to a changed setting.
Solution: Add the OptionSet autocommand event. (Christian Brabandt)
537443018d
This commit is contained in:
@@ -258,6 +258,7 @@ Name triggered by ~
|
|||||||
|Syntax| when the 'syntax' option has been set
|
|Syntax| when the 'syntax' option has been set
|
||||||
|EncodingChanged| after the 'encoding' option has been changed
|
|EncodingChanged| after the 'encoding' option has been changed
|
||||||
|TermChanged| after the value of 'term' has changed
|
|TermChanged| after the value of 'term' has changed
|
||||||
|
|OptionSet| after setting any option
|
||||||
|
|
||||||
Startup and exit
|
Startup and exit
|
||||||
|VimEnter| after doing all the startup stuff
|
|VimEnter| after doing all the startup stuff
|
||||||
@@ -745,6 +746,24 @@ MenuPopup Just before showing the popup menu (under the
|
|||||||
o Operator-pending
|
o Operator-pending
|
||||||
i Insert
|
i Insert
|
||||||
c Command line
|
c Command line
|
||||||
|
*OptionSet*
|
||||||
|
OptionSet After setting an option. The pattern is
|
||||||
|
matched against the long option name.
|
||||||
|
The |v:option_old| variable indicates the
|
||||||
|
old option value, |v:option_new| variable
|
||||||
|
indicates the newly set value, the
|
||||||
|
|v:option_type| variable indicates whether
|
||||||
|
it's global or local scoped and |<amatch>|
|
||||||
|
indicates what option has been set.
|
||||||
|
|
||||||
|
Note: It's a bad idea, to reset an option
|
||||||
|
during this autocommand, since this will
|
||||||
|
probably break plugins. You can always use
|
||||||
|
|noa| to prevent triggering this autocommand.
|
||||||
|
Could be used, to check for existence of the
|
||||||
|
'backupdir' and 'undodir' options and create
|
||||||
|
directories, if they don't exist yet.
|
||||||
|
|
||||||
*QuickFixCmdPre*
|
*QuickFixCmdPre*
|
||||||
QuickFixCmdPre Before a quickfix command is run (|:make|,
|
QuickFixCmdPre Before a quickfix command is run (|:make|,
|
||||||
|:lmake|, |:grep|, |:lgrep|, |:grepadd|,
|
|:lmake|, |:grep|, |:lgrep|, |:grepadd|,
|
||||||
|
@@ -1535,6 +1535,15 @@ v:oldfiles List of file names that is loaded from the |shada| file on
|
|||||||
than String this will cause trouble.
|
than String this will cause trouble.
|
||||||
{only when compiled with the |+shada| feature}
|
{only when compiled with the |+shada| feature}
|
||||||
|
|
||||||
|
*v:option_new*
|
||||||
|
v:option_new New value of the option. Valid while executing an |OptionSet|
|
||||||
|
autocommand.
|
||||||
|
*v:option_old*
|
||||||
|
v:option_old Old value of the option. Valid while executing an |OptionSet|
|
||||||
|
autocommand.
|
||||||
|
*v:option_type*
|
||||||
|
v:option_type Scope of the set command. Valid while executing an
|
||||||
|
|OptionSet| autocommand. Can be either "global" or "local"
|
||||||
*v:operator* *operator-variable*
|
*v:operator* *operator-variable*
|
||||||
v:operator The last operator given in Normal mode. This is a single
|
v:operator The last operator given in Normal mode. This is a single
|
||||||
character except for commands starting with <g> or <z>,
|
character except for commands starting with <g> or <z>,
|
||||||
|
@@ -57,6 +57,7 @@ return {
|
|||||||
'InsertLeave', -- when leaving Insert mode
|
'InsertLeave', -- when leaving Insert mode
|
||||||
'JobActivity', -- when job sent some data
|
'JobActivity', -- when job sent some data
|
||||||
'MenuPopup', -- just before popup menu is displayed
|
'MenuPopup', -- just before popup menu is displayed
|
||||||
|
'OptionSet', -- after setting any option
|
||||||
'QuickFixCmdPost', -- after :make, :grep etc.
|
'QuickFixCmdPost', -- after :make, :grep etc.
|
||||||
'QuickFixCmdPre', -- before :make, :grep etc.
|
'QuickFixCmdPre', -- before :make, :grep etc.
|
||||||
'QuitPre', -- before :quit
|
'QuitPre', -- before :quit
|
||||||
|
@@ -382,6 +382,9 @@ static struct vimvar {
|
|||||||
{VV_NAME("progpath", VAR_STRING), VV_RO},
|
{VV_NAME("progpath", VAR_STRING), VV_RO},
|
||||||
{VV_NAME("command_output", VAR_STRING), 0},
|
{VV_NAME("command_output", VAR_STRING), 0},
|
||||||
{VV_NAME("completed_item", VAR_DICT), VV_RO},
|
{VV_NAME("completed_item", VAR_DICT), VV_RO},
|
||||||
|
{VV_NAME("option_new", VAR_STRING), VV_RO},
|
||||||
|
{VV_NAME("option_old", VAR_STRING), VV_RO},
|
||||||
|
{VV_NAME("option_type", VAR_STRING), VV_RO},
|
||||||
{VV_NAME("msgpack_types", VAR_DICT), VV_RO},
|
{VV_NAME("msgpack_types", VAR_DICT), VV_RO},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -21247,9 +21250,14 @@ void ex_oldfiles(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* reset v:option_new, v:option_old and v:option_type */
|
||||||
|
void
|
||||||
|
reset_v_option_vars(void)
|
||||||
|
{
|
||||||
|
set_vim_var_string(VV_OPTION_NEW, NULL, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_OLD, NULL, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_TYPE, NULL, -1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adjust a filename, according to a string of modifiers.
|
* Adjust a filename, according to a string of modifiers.
|
||||||
|
@@ -108,6 +108,9 @@ enum {
|
|||||||
VV_PROGPATH,
|
VV_PROGPATH,
|
||||||
VV_COMMAND_OUTPUT,
|
VV_COMMAND_OUTPUT,
|
||||||
VV_COMPLETED_ITEM,
|
VV_COMPLETED_ITEM,
|
||||||
|
VV_OPTION_NEW,
|
||||||
|
VV_OPTION_OLD,
|
||||||
|
VV_OPTION_TYPE,
|
||||||
VV_MSGPACK_TYPES,
|
VV_MSGPACK_TYPES,
|
||||||
VV_LEN, /* number of v: vars */
|
VV_LEN, /* number of v: vars */
|
||||||
};
|
};
|
||||||
|
@@ -6426,7 +6426,7 @@ apply_autocmds_group (
|
|||||||
* invalid.
|
* invalid.
|
||||||
*/
|
*/
|
||||||
if (fname_io == NULL) {
|
if (fname_io == NULL) {
|
||||||
if (event == EVENT_COLORSCHEME)
|
if (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET)
|
||||||
autocmd_fname = NULL;
|
autocmd_fname = NULL;
|
||||||
else if (fname != NULL && *fname != NUL)
|
else if (fname != NULL && *fname != NUL)
|
||||||
autocmd_fname = fname;
|
autocmd_fname = fname;
|
||||||
@@ -6476,6 +6476,7 @@ apply_autocmds_group (
|
|||||||
if (event == EVENT_COLORSCHEME
|
if (event == EVENT_COLORSCHEME
|
||||||
|| event == EVENT_FILETYPE
|
|| event == EVENT_FILETYPE
|
||||||
|| event == EVENT_FUNCUNDEFINED
|
|| event == EVENT_FUNCUNDEFINED
|
||||||
|
|| event == EVENT_OPTIONSET
|
||||||
|| event == EVENT_QUICKFIXCMDPOST
|
|| event == EVENT_QUICKFIXCMDPOST
|
||||||
|| event == EVENT_QUICKFIXCMDPRE
|
|| event == EVENT_QUICKFIXCMDPRE
|
||||||
|| event == EVENT_REMOTEREPLY
|
|| event == EVENT_REMOTEREPLY
|
||||||
|
@@ -1511,9 +1511,10 @@ do_set (
|
|||||||
} else if (opt_idx >= 0) { /* string */
|
} else if (opt_idx >= 0) { /* string */
|
||||||
char_u *save_arg = NULL;
|
char_u *save_arg = NULL;
|
||||||
char_u *s = NULL;
|
char_u *s = NULL;
|
||||||
char_u *oldval; /* previous value if *varp */
|
char_u *oldval = NULL; /* previous value if *varp */
|
||||||
char_u *newval;
|
char_u *newval;
|
||||||
char_u *origval;
|
char_u *origval = NULL;
|
||||||
|
char_u *saved_origval = NULL;
|
||||||
unsigned newlen;
|
unsigned newlen;
|
||||||
int comma;
|
int comma;
|
||||||
int bs;
|
int bs;
|
||||||
@@ -1780,6 +1781,11 @@ do_set (
|
|||||||
/* Set the new value. */
|
/* Set the new value. */
|
||||||
*(char_u **)(varp) = newval;
|
*(char_u **)(varp) = newval;
|
||||||
|
|
||||||
|
if (!starting && origval != NULL)
|
||||||
|
/* origval may be freed by
|
||||||
|
* did_set_string_option(), make a copy. */
|
||||||
|
saved_origval = vim_strsave(origval);
|
||||||
|
|
||||||
/* Handle side effects, and set the global value for
|
/* Handle side effects, and set the global value for
|
||||||
* ":set" on local options. */
|
* ":set" on local options. */
|
||||||
errmsg = did_set_string_option(opt_idx, (char_u **)varp,
|
errmsg = did_set_string_option(opt_idx, (char_u **)varp,
|
||||||
@@ -1788,6 +1794,20 @@ do_set (
|
|||||||
/* If error detected, print the error message. */
|
/* If error detected, print the error message. */
|
||||||
if (errmsg != NULL)
|
if (errmsg != NULL)
|
||||||
goto skip;
|
goto skip;
|
||||||
|
if (saved_origval != NULL) {
|
||||||
|
char_u buf_type[7];
|
||||||
|
|
||||||
|
sprintf((char *)buf_type, "%s",
|
||||||
|
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||||
|
set_vim_var_string(VV_OPTION_NEW, newval, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
||||||
|
apply_autocmds(EVENT_OPTIONSET,
|
||||||
|
(char_u *)options[opt_idx].fullname,
|
||||||
|
NULL, FALSE, NULL);
|
||||||
|
reset_v_option_vars();
|
||||||
|
xfree(saved_origval);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// key code option(FIXME(tarruda): Show a warning or something
|
// key code option(FIXME(tarruda): Show a warning or something
|
||||||
// similar)
|
// similar)
|
||||||
@@ -2337,6 +2357,7 @@ set_string_option (
|
|||||||
char_u *s;
|
char_u *s;
|
||||||
char_u **varp;
|
char_u **varp;
|
||||||
char_u *oldval;
|
char_u *oldval;
|
||||||
|
char_u *saved_oldval = NULL;
|
||||||
char_u *r = NULL;
|
char_u *r = NULL;
|
||||||
|
|
||||||
if (options[opt_idx].var == NULL) /* don't set hidden option */
|
if (options[opt_idx].var == NULL) /* don't set hidden option */
|
||||||
@@ -2350,10 +2371,27 @@ set_string_option (
|
|||||||
: opt_flags);
|
: opt_flags);
|
||||||
oldval = *varp;
|
oldval = *varp;
|
||||||
*varp = s;
|
*varp = s;
|
||||||
|
|
||||||
|
if (!starting)
|
||||||
|
saved_oldval = vim_strsave(oldval);
|
||||||
|
|
||||||
if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
|
if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
|
||||||
opt_flags)) == NULL)
|
opt_flags)) == NULL)
|
||||||
did_set_option(opt_idx, opt_flags, TRUE);
|
did_set_option(opt_idx, opt_flags, TRUE);
|
||||||
|
|
||||||
|
/* call autocommand after handling side effects */
|
||||||
|
if (saved_oldval != NULL) {
|
||||||
|
char_u buf_type[7];
|
||||||
|
sprintf((char *)buf_type, "%s",
|
||||||
|
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||||
|
set_vim_var_string(VV_OPTION_NEW, s, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_OLD, oldval, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
||||||
|
apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
|
||||||
|
reset_v_option_vars();
|
||||||
|
xfree(saved_oldval);
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3822,8 +3860,22 @@ set_bool_option (
|
|||||||
* End of handling side effects for bool options.
|
* End of handling side effects for bool options.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* after handling side effects, call autocommand */
|
||||||
|
|
||||||
options[opt_idx].flags |= P_WAS_SET;
|
options[opt_idx].flags |= P_WAS_SET;
|
||||||
|
|
||||||
|
if (!starting) {
|
||||||
|
char_u buf_old[2], buf_new[2], buf_type[7];
|
||||||
|
snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
|
||||||
|
snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
|
||||||
|
sprintf((char *)buf_type, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||||
|
set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
||||||
|
apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
|
||||||
|
reset_v_option_vars();
|
||||||
|
}
|
||||||
|
|
||||||
comp_col(); /* in case 'ruler' or 'showcmd' changed */
|
comp_col(); /* in case 'ruler' or 'showcmd' changed */
|
||||||
if (curwin->w_curswant != MAXCOL
|
if (curwin->w_curswant != MAXCOL
|
||||||
&& (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
|
&& (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
|
||||||
@@ -4195,6 +4247,18 @@ set_num_option (
|
|||||||
|
|
||||||
options[opt_idx].flags |= P_WAS_SET;
|
options[opt_idx].flags |= P_WAS_SET;
|
||||||
|
|
||||||
|
if (!starting && errmsg == NULL) {
|
||||||
|
char_u buf_old[11], buf_new[11], buf_type[7];
|
||||||
|
snprintf((char *)buf_old, 10, "%ld", old_value);
|
||||||
|
snprintf((char *)buf_new, 10, "%ld", value);
|
||||||
|
snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||||
|
set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
||||||
|
apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
|
||||||
|
reset_v_option_vars();
|
||||||
|
}
|
||||||
|
|
||||||
comp_col(); /* in case 'columns' or 'ls' changed */
|
comp_col(); /* in case 'columns' or 'ls' changed */
|
||||||
if (curwin->w_curswant != MAXCOL
|
if (curwin->w_curswant != MAXCOL
|
||||||
&& (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
|
&& (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
|
||||||
|
@@ -25,6 +25,7 @@ SCRIPTS := test_eval.out \
|
|||||||
test83.out \
|
test83.out \
|
||||||
test88.out \
|
test88.out \
|
||||||
test_listlbr.out \
|
test_listlbr.out \
|
||||||
|
test_autocmd_option.out \
|
||||||
test_breakindent.out \
|
test_breakindent.out \
|
||||||
test_charsearch.out \
|
test_charsearch.out \
|
||||||
test_close_count.out \
|
test_close_count.out \
|
||||||
|
68
src/nvim/testdir/test_autocmd_option.in
Normal file
68
src/nvim/testdir/test_autocmd_option.in
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
Test for option autocommand
|
||||||
|
|
||||||
|
STARTTEST
|
||||||
|
:so small.vim
|
||||||
|
:if !has("eval") || !has("autocmd") | e! test.ok | w! test.out | qa! | endif
|
||||||
|
:fu! AutoCommand(match)
|
||||||
|
: let c=g:testcase
|
||||||
|
: let item=remove(g:options, 0)
|
||||||
|
: let c.=printf("Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\n", item[0], item[1], item[2], item[3])
|
||||||
|
: let c.=printf("Autocmd Option: <%s>,", a:match)
|
||||||
|
: let c.=printf(" OldVal: <%s>,", v:option_old)
|
||||||
|
: let c.=printf(" NewVal: <%s>,", v:option_new)
|
||||||
|
: let c.=printf(" Scope: <%s>\n", v:option_type)
|
||||||
|
: call setreg('r', printf("%s\n%s", getreg('r'), c))
|
||||||
|
:endfu
|
||||||
|
:au OptionSet * :call AutoCommand(expand("<amatch>"))
|
||||||
|
:let g:testcase="1: Setting number option\n"
|
||||||
|
:let g:options=[['number', 0, 1, 'global']]
|
||||||
|
:set nu
|
||||||
|
:let g:testcase="2: Setting local number option\n"
|
||||||
|
:let g:options=[['number', 1, 0, 'local']]
|
||||||
|
:setlocal nonu
|
||||||
|
:let g:testcase="3: Setting global number option\n"
|
||||||
|
:let g:options=[['number', 1, 0, 'global']]
|
||||||
|
:setglobal nonu
|
||||||
|
:let g:testcase="4: Setting local autoindent option\n"
|
||||||
|
:let g:options=[['autoindent', 1, 0, 'local']]
|
||||||
|
:setlocal noai
|
||||||
|
:let g:testcase="5: Setting global autoindent option\n"
|
||||||
|
:let g:options=[['autoindent', 1, 0, 'global']]
|
||||||
|
:setglobal noai
|
||||||
|
:let g:testcase="6: Setting global autoindent option\n"
|
||||||
|
:let g:options=[['autoindent', 0, 1, 'global']]
|
||||||
|
:set ai!
|
||||||
|
: Should not print anything, use :noa
|
||||||
|
:noa :set nonu
|
||||||
|
:let g:testcase="7: Setting several global list and number option\n"
|
||||||
|
:let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]
|
||||||
|
:set list nu
|
||||||
|
:noa set nolist nonu
|
||||||
|
:let g:testcase="8: Setting global acd\n"
|
||||||
|
:let g:options=[['autochdir', 0, 1, 'global']]
|
||||||
|
:setlocal acd
|
||||||
|
:let g:testcase="9: Setting global autoread\n"
|
||||||
|
:let g:options=[['autoread', 1, 0, 'global']]
|
||||||
|
:set noar
|
||||||
|
:let g:testcase="10: Setting local autoread\n"
|
||||||
|
:let g:options=[['autoread', 1, 0, 'local']]
|
||||||
|
:setlocal noar
|
||||||
|
:let g:testcase="11: Setting global autoread\n"
|
||||||
|
:let g:options=[['autoread', 0, 1, 'global']]
|
||||||
|
:setglobal invar
|
||||||
|
:let g:testcase="12: Setting option backspace through :let\n"
|
||||||
|
:let g:options=[['backspace', 'indent,eol,start', '', 'global']]
|
||||||
|
:let &bs=""
|
||||||
|
:let g:testcase="13: Setting option backspace through setbufvar()\n"
|
||||||
|
:let g:options=[['backup', '', '1', 'local']]
|
||||||
|
: "try twice, first time, shouldn't trigger because option name is invalid, second time, it should trigger
|
||||||
|
:call setbufvar(1, '&l:bk', 1)
|
||||||
|
: "should trigger, use correct option name
|
||||||
|
:call setbufvar(1, '&backup', 1)
|
||||||
|
:" Write register now, because next test shouldn't output anything.
|
||||||
|
:$put r
|
||||||
|
:let @r=''
|
||||||
|
:%w! test.out
|
||||||
|
:qa!
|
||||||
|
ENDTEST
|
||||||
|
dummy text
|
129
src/nvim/testdir/test_autocmd_option.ok
Normal file
129
src/nvim/testdir/test_autocmd_option.ok
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
Test for option autocommand
|
||||||
|
|
||||||
|
STARTTEST
|
||||||
|
:so small.vim
|
||||||
|
:if !has("eval") || !has("autocmd") | e! test.ok | w! test.out | qa! | endif
|
||||||
|
:fu! AutoCommand(match)
|
||||||
|
: let c=g:testcase
|
||||||
|
: let item=remove(g:options, 0)
|
||||||
|
: let c.=printf("Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\n", item[0], item[1], item[2], item[3])
|
||||||
|
: let c.=printf("Autocmd Option: <%s>,", a:match)
|
||||||
|
: let c.=printf(" OldVal: <%s>,", v:option_old)
|
||||||
|
: let c.=printf(" NewVal: <%s>,", v:option_new)
|
||||||
|
: let c.=printf(" Scope: <%s>\n", v:option_type)
|
||||||
|
: call setreg('r', printf("%s\n%s", getreg('r'), c))
|
||||||
|
:endfu
|
||||||
|
:au OptionSet * :call AutoCommand(expand("<amatch>"))
|
||||||
|
:let g:testcase="1: Setting number option\n"
|
||||||
|
:let g:options=[['number', 0, 1, 'global']]
|
||||||
|
:set nu
|
||||||
|
:let g:testcase="2: Setting local number option\n"
|
||||||
|
:let g:options=[['number', 1, 0, 'local']]
|
||||||
|
:setlocal nonu
|
||||||
|
:let g:testcase="3: Setting global number option\n"
|
||||||
|
:let g:options=[['number', 1, 0, 'global']]
|
||||||
|
:setglobal nonu
|
||||||
|
:let g:testcase="4: Setting local autoindent option\n"
|
||||||
|
:let g:options=[['autoindent', 0, 1, 'local']]
|
||||||
|
:setlocal ai
|
||||||
|
:let g:testcase="5: Setting global autoindent option\n"
|
||||||
|
:let g:options=[['autoindent', 0, 1, 'global']]
|
||||||
|
:setglobal ai
|
||||||
|
:let g:testcase="6: Setting global autoindent option\n"
|
||||||
|
:let g:options=[['autoindent', 1, 0, 'global']]
|
||||||
|
:set ai!
|
||||||
|
: Should not print anything, use :noa
|
||||||
|
:noa :set nonu
|
||||||
|
:let g:testcase="7: Setting several global list and number option\n"
|
||||||
|
:let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]
|
||||||
|
:set list nu
|
||||||
|
:noa set nolist nonu
|
||||||
|
:let g:testcase="8: Setting global acd\n"
|
||||||
|
:let g:options=[['autochdir', 0, 1, 'global']]
|
||||||
|
:setlocal acd
|
||||||
|
:let g:testcase="9: Setting global autoread\n"
|
||||||
|
:let g:options=[['autoread', 0, 1, 'global']]
|
||||||
|
:set ar
|
||||||
|
:let g:testcase="10: Setting local autoread\n"
|
||||||
|
:let g:options=[['autoread', 0, 1, 'local']]
|
||||||
|
:setlocal ar
|
||||||
|
:let g:testcase="11: Setting global autoread\n"
|
||||||
|
:let g:options=[['autoread', 1, 0, 'global']]
|
||||||
|
:setglobal invar
|
||||||
|
:let g:testcase="12: Setting option backspace through :let\n"
|
||||||
|
:let g:options=[['backspace', '', 'eol,indent,start', 'global']]
|
||||||
|
:let &bs="eol,indent,start"
|
||||||
|
:let g:testcase="13: Setting option backspace through setbufvar()\n"
|
||||||
|
:let g:options=[['backup', '', '1', 'local']]
|
||||||
|
: "try twice, first time, shouldn't trigger because option name is invalid, second time, it should trigger
|
||||||
|
:call setbufvar(1, '&l:bk', 1)
|
||||||
|
: "should trigger, use correct option name
|
||||||
|
:call setbufvar(1, '&backup', 1)
|
||||||
|
:" Write register now, because next test shouldn't output anything.
|
||||||
|
:$put r
|
||||||
|
:let @r=''
|
||||||
|
:let g:testcase="\n14: Setting key option, shouldn't trigger\n"
|
||||||
|
:let g:options=[['key', 'invalid', 'invalid1', 'invalid']]
|
||||||
|
:setlocal key=blah
|
||||||
|
:setlocal key=
|
||||||
|
:$put =g:testcase
|
||||||
|
:%w! test.out
|
||||||
|
:qa!
|
||||||
|
ENDTEST
|
||||||
|
dummy text
|
||||||
|
|
||||||
|
1: Setting number option
|
||||||
|
Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
|
||||||
|
2: Setting local number option
|
||||||
|
Expected: Name: <number>, Oldval: <1>, NewVal: <0>, Scope: <local>
|
||||||
|
Autocmd Option: <number>, OldVal: <1>, NewVal: <0>, Scope: <local>
|
||||||
|
|
||||||
|
3: Setting global number option
|
||||||
|
Expected: Name: <number>, Oldval: <1>, NewVal: <0>, Scope: <global>
|
||||||
|
Autocmd Option: <number>, OldVal: <1>, NewVal: <0>, Scope: <global>
|
||||||
|
|
||||||
|
4: Setting local autoindent option
|
||||||
|
Expected: Name: <autoindent>, Oldval: <1>, NewVal: <0>, Scope: <local>
|
||||||
|
Autocmd Option: <autoindent>, OldVal: <1>, NewVal: <0>, Scope: <local>
|
||||||
|
|
||||||
|
5: Setting global autoindent option
|
||||||
|
Expected: Name: <autoindent>, Oldval: <1>, NewVal: <0>, Scope: <global>
|
||||||
|
Autocmd Option: <autoindent>, OldVal: <1>, NewVal: <0>, Scope: <global>
|
||||||
|
|
||||||
|
6: Setting global autoindent option
|
||||||
|
Expected: Name: <autoindent>, Oldval: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
Autocmd Option: <autoindent>, OldVal: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
|
||||||
|
7: Setting several global list and number option
|
||||||
|
Expected: Name: <list>, Oldval: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
Autocmd Option: <list>, OldVal: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
|
||||||
|
7: Setting several global list and number option
|
||||||
|
Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
|
||||||
|
8: Setting global acd
|
||||||
|
Expected: Name: <autochdir>, Oldval: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
Autocmd Option: <autochdir>, OldVal: <0>, NewVal: <1>, Scope: <local>
|
||||||
|
|
||||||
|
9: Setting global autoread
|
||||||
|
Expected: Name: <autoread>, Oldval: <1>, NewVal: <0>, Scope: <global>
|
||||||
|
Autocmd Option: <autoread>, OldVal: <1>, NewVal: <0>, Scope: <global>
|
||||||
|
|
||||||
|
10: Setting local autoread
|
||||||
|
Expected: Name: <autoread>, Oldval: <1>, NewVal: <0>, Scope: <local>
|
||||||
|
Autocmd Option: <autoread>, OldVal: <1>, NewVal: <0>, Scope: <local>
|
||||||
|
|
||||||
|
11: Setting global autoread
|
||||||
|
Expected: Name: <autoread>, Oldval: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
Autocmd Option: <autoread>, OldVal: <0>, NewVal: <1>, Scope: <global>
|
||||||
|
|
||||||
|
12: Setting option backspace through :let
|
||||||
|
Expected: Name: <backspace>, Oldval: <indent,eol,start>, NewVal: <>, Scope: <global>
|
||||||
|
Autocmd Option: <backspace>, OldVal: <indent,eol,start>, NewVal: <>, Scope: <global>
|
||||||
|
|
||||||
|
13: Setting option backspace through setbufvar()
|
||||||
|
Expected: Name: <backup>, Oldval: <>, NewVal: <1>, Scope: <local>
|
||||||
|
Autocmd Option: <backup>, OldVal: <0>, NewVal: <1>, Scope: <local>
|
@@ -210,7 +210,7 @@ static int included_patches[] = {
|
|||||||
// 789,
|
// 789,
|
||||||
// 788 NA
|
// 788 NA
|
||||||
// 787,
|
// 787,
|
||||||
// 786,
|
786,
|
||||||
// 785,
|
// 785,
|
||||||
784,
|
784,
|
||||||
// 783 NA
|
// 783 NA
|
||||||
|
Reference in New Issue
Block a user