Gary Johnson wrote:
> > > Thanks for adding the DiffUpdated autocommand event.
> > >
> > > I've been trying to use the DiffUpdated and OptionSet autocommand
> > > events to update some option settings and I think I've found a bug
> > > in the OptionSet event: v:option_old and v:option_new are not set
> > > when the option is diff. I'm using Vim 8.1.401.
> > >
> > > When I execute the following autocommand definition,
> > >
> > > :autocmd OptionSet diff echo "OptionSet diff" v:option_old
> > > v:option_new
> > >
> > > followed by
> > >
> > > :set diff
> > > :set nodiff
> > >
> > > all I see displayed in the status line for each of those is
> > >
> > > OptionSet diff
> > >
> > > but no values for either v:option_old or v:option_new.
> > >
> > > Repeating the experiment, but replacing "diff" by "number" yields
> > > the expected results:
> > >
> > > OptionSet number 0 1
> > > OptionSet number 1 0
> >
> > Well, it works just fine for me. No idea why it doesn't work for you.
>
> I just tried it again, this time starting vim as
>
> $ vim -N -u NONE -i NONE
>
> and it works correctly.
>
> I then tried a number of experiments, including inserting
> autocommands such as this one among the other "OptionSet diff"
> autocommands I've defined.
>
> autocmd OptionSet diff echo "OptionSet diff A" v:option_old v:option_new
>
> I changed the letter A to a different letter for each autocommand so
> that I could tell their outputs apart.
>
> I discovered that the outputs were correct up to a point, then the
> values of v:option_old and v:option_new became empty. That occurred
> after the following autocommand.
>
> autocmd OptionSet diff if &diff && !exists("g:ve") | let g:ve = &ve | set
> ve=all | endif
>
> I don't know what's going on, but something in that autocommand
> causes v:option_old and v:option_new to be cleared.
It's the ":set ve=all" command, it tries triggering OptionSet again,
which probably doesn't do anything because of nesting, but it does clear
the v:option_new and v:option_old variables.
Perhaps we can do this:
--- git/vim81/src/option.c 2018-09-13 20:31:47.111018149 +0200
+++ option.c 2018-09-19 23:18:45.761370196 +0200
@@ -4359,7 +4359,9 @@
char_u *oldval,
char_u *newval)
{
- if (oldval != NULL && newval != NULL)
+ // Don't do this recursively.
+ if (oldval != NULL && newval != NULL
+ && get_vim_var_str(VV_OPTION_TYPE) == NULL)
{
char_u buf_type[7];
@@ -8858,9 +8860,11 @@
options[opt_idx].flags |= P_WAS_SET;
#if defined(FEAT_EVAL)
- if (!starting)
+ // Don't do this while starting up or recursively.
+ if (!starting && get_vim_var_str(VV_OPTION_TYPE) == NULL)
{
char_u buf_old[2], buf_new[2], buf_type[7];
+
vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ?
"local" : "global");
@@ -9415,7 +9419,8 @@
options[opt_idx].flags |= P_WAS_SET;
#if defined(FEAT_EVAL)
- if (!starting && errmsg == NULL)
+ // Don't do this while starting up, failure or recursively.
+ if (!starting && errmsg == NULL && get_vim_var_str(VV_OPTION_TYPE) == NULL)
{
char_u buf_old[11], buf_new[11], buf_type[7];
vim_snprintf((char *)buf_old, 10, "%ld", old_value);
--
The sooner you fall behind, the more time you'll have to catch up.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.