There was a small error in the patch,
attached again.
Mit freundlichen Grüßen
Christian
--
Aus Murphy's Gesetze:
Das einzige Backup, das du je brauchst, ist das, für das du keine Zeit
hattest.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -17619,7 +17619,13 @@ setwinvar(argvars, rettv, off)
if (win != NULL && varname != NULL && varp != NULL)
{
#ifdef FEAT_WINDOWS
- if (switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK)
+ if (win == curwin && tp == curtab)
+ {
+ save_curtab = curtab;
+ save_curwin = curwin;
+ }
+
+ if ((win == curwin && tp == curtab) || switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK)
#endif
{
if (*varname == '&')
@@ -17631,8 +17637,17 @@ setwinvar(argvars, rettv, off)
++varname;
numval = get_tv_number_chk(varp, &error);
strval = get_tv_string_buf_chk(varp, nbuf);
+# ifdef FEAT_AUTOCMD
+ /* was blocked by switch_win */
+ if (has_autocmd_optionset())
+ unblock_autocmds();
+# endif
if (!error && strval != NULL)
set_option_value(varname, numval, strval, OPT_LOCAL);
+# ifdef FEAT_AUTOCMD
+ if (has_autocmd_optionset())
+ block_autocmds();
+# endif
}
else
{
@@ -17647,7 +17662,8 @@ setwinvar(argvars, rettv, off)
}
}
#ifdef FEAT_WINDOWS
- restore_win(save_curwin, save_curtab, TRUE);
+ if (save_curwin != curwin || save_curtab != curtab)
+ restore_win(save_curwin, save_curtab, TRUE);
#endif
}
}
diff --git a/src/fileio.c b/src/fileio.c
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -9765,6 +9765,12 @@ getnextac(c, cookie, indent)
return retval;
}
+/* Return TRUE if there exists an OptionSet autocommand */
+ int
+has_autocmd_optionset()
+{
+ return first_autopat[(int)EVENT_OPTIONSET] != NULL;
+}
/*
* Return TRUE if there is a matching autocommand for "fname".
* To account for buffer-local autocommands, function needs to know
diff --git a/src/proto/fileio.pro b/src/proto/fileio.pro
--- a/src/proto/fileio.pro
+++ b/src/proto/fileio.pro
@@ -53,6 +53,7 @@ void block_autocmds __ARGS((void));
void unblock_autocmds __ARGS((void));
int is_autocmd_blocked __ARGS((void));
char_u *getnextac __ARGS((int c, void *cookie, int indent));
+int has_autocmd_optionset __ARGS((void));
int has_autocmd __ARGS((event_T event, char_u *sfname, buf_T *buf));
char_u *get_augroup_name __ARGS((expand_T *xp, int idx));
char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd));
diff --git a/src/testdir/test_autocmd_option.in b/src/testdir/test_autocmd_option.in
--- a/src/testdir/test_autocmd_option.in
+++ b/src/testdir/test_autocmd_option.in
@@ -59,14 +59,18 @@ STARTTEST
:call setbufvar(1, '&l:bk', 1)
: "should trigger, use correct option name
:call setbufvar(1, '&backup', 1)
+:let g:testcase="14: Setting number option using setwinvar\n"
+:let g:options=[['number', 0, 1, 'local']]
+:call setwinvar(0, '&number', 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:testcase="\n15: Setting key option, shouldn't trigger\n"
:let g:options=[['key', 'invalid', 'invalid1', 'invalid']]
:setlocal key=blah
:setlocal key=
:$put =g:testcase
+:$put r
:/^dummy text/,$w! test.out
:qa!
ENDTEST
diff --git a/src/testdir/test_autocmd_option.ok b/src/testdir/test_autocmd_option.ok
--- a/src/testdir/test_autocmd_option.ok
+++ b/src/testdir/test_autocmd_option.ok
@@ -56,4 +56,9 @@ 13: Setting option backspace through set
Expected: Name: <backup>, Oldval: <>, NewVal: <1>, Scope: <local>
Autocmd Option: <backup>, OldVal: <0>, NewVal: <1>, Scope: <local>
-14: Setting key option, shouldn't trigger
+14: Setting number option using setwinvar
+Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <local>
+Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <local>
+
+15: Setting key option, shouldn't trigger
+