diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2015-12-12 17:43:23 -0500 | 
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2015-12-12 17:43:23 -0500 | 
| commit | cc203e4b93d920cb749f80336504d7e6df0081a2 (patch) | |
| tree | bf8837d4b3d9de8dd26f1a3cd5a6de51c84e1567 /src/nvim/option.c | |
| parent | f37ad6af3601993e9d12a7761bf60b41a640f53d (diff) | |
| parent | 1b56425662068a40cf3a19cd47ac79d7511840b5 (diff) | |
| download | rneovim-cc203e4b93d920cb749f80336504d7e6df0081a2.tar.gz rneovim-cc203e4b93d920cb749f80336504d7e6df0081a2.tar.bz2 rneovim-cc203e4b93d920cb749f80336504d7e6df0081a2.zip | |
Merge pull request #3753 from watiko/vim-7.4.790
Vim 7.4.{786,787,789,790}
Diffstat (limited to 'src/nvim/option.c')
| -rw-r--r-- | src/nvim/option.c | 93 | 
1 files changed, 88 insertions, 5 deletions
| diff --git a/src/nvim/option.c b/src/nvim/option.c index f5080c7a91..dbcd230186 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1503,9 +1503,10 @@ do_set (            } else if (opt_idx >= 0) {                      /* string */              char_u      *save_arg = 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      *origval; +            char_u      *origval = NULL; +            char_u      *saved_origval = NULL;              unsigned newlen;              int comma;              int bs; @@ -1772,14 +1773,37 @@ do_set (              /* Set the new value. */              *(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               * ":set" on local options. */              errmsg = did_set_string_option(opt_idx, (char_u **)varp,                  new_value_alloced, oldval, errbuf, opt_flags); -            /* If error detected, print the error message. */ -            if (errmsg != NULL) +            // If error detected, print the error message. +            if (errmsg != NULL) { +              xfree(saved_origval);                goto skip; +            } + +            if (saved_origval != NULL) { +              char_u buf_type[7]; +              vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s", +                           (opt_flags & OPT_LOCAL) ? "local" : "global"); +              set_vim_var_string(VV_OPTION_NEW, +                                 *(char_u **)varp, -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 {              // key code option(FIXME(tarruda): Show a warning or something              // similar) @@ -2329,6 +2353,7 @@ set_string_option (    char_u      *s;    char_u      **varp;    char_u      *oldval; +  char_u      *saved_oldval = NULL;    char_u      *r = NULL;    if (options[opt_idx].var == NULL)     /* don't set hidden option */ @@ -2342,10 +2367,30 @@ set_string_option (        : opt_flags);    oldval = *varp;    *varp = s; -  if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, + +  if (!starting) { +    saved_oldval = vim_strsave(oldval); +  } + +  if ((r = did_set_string_option(opt_idx, varp, (int)true, oldval, NULL,            opt_flags)) == NULL)      did_set_option(opt_idx, opt_flags, TRUE); +  // call autocommand after handling side effects +  if (saved_oldval != NULL) { +    char_u buf_type[7]; +    vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s", +                 (opt_flags & OPT_LOCAL) ? "local" : "global"); +    set_vim_var_string(VV_OPTION_NEW, *varp, -1); +    set_vim_var_string(VV_OPTION_OLD, saved_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;  } @@ -3814,8 +3859,29 @@ set_bool_option (     * End of handling side effects for bool options.     */ +  // after handling side effects, call autocommand +    options[opt_idx].flags |= P_WAS_SET; +  if (!starting) { +    char_u buf_old[2]; +    char_u buf_new[2]; +    char_u buf_type[7]; +    vim_snprintf((char *)buf_old, ARRAY_SIZE(buf_old), "%d", +                 old_value ? true: false); +    vim_snprintf((char *)buf_new, ARRAY_SIZE(buf_new), "%d", +                 value ? true: false); +    vim_snprintf((char *)buf_type, ARRAY_SIZE(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 */    if (curwin->w_curswant != MAXCOL        && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) @@ -4187,6 +4253,23 @@ set_num_option (    options[opt_idx].flags |= P_WAS_SET; +  if (!starting && errmsg == NULL) { +    char_u buf_old[NUMBUFLEN]; +    char_u buf_new[NUMBUFLEN]; +    char_u buf_type[7]; +    vim_snprintf((char *)buf_old, ARRAY_SIZE(buf_old), "%ld", old_value); +    vim_snprintf((char *)buf_new, ARRAY_SIZE(buf_new), "%ld", value); +    vim_snprintf((char *)buf_type, ARRAY_SIZE(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 'columns' or 'ls' changed */    if (curwin->w_curswant != MAXCOL        && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) | 
