diff options
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index cc7f8333ff..ed058c420d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1147,7 +1147,7 @@ do_set ( int afterchar; /* character just after option name */ int len; int i; - long value; + varnumber_T value; int key; uint32_t flags; /* flags for current option */ char_u *varp = NULL; /* pointer to variable for current option */ @@ -1480,7 +1480,7 @@ do_set ( if (removing) { value = *(long *)varp - value; } - errmsg = (char_u *)set_num_option(opt_idx, varp, value, + errmsg = (char_u *)set_num_option(opt_idx, varp, (long)value, errbuf, sizeof(errbuf), opt_flags); } else if (opt_idx >= 0) { // String. @@ -3582,7 +3582,9 @@ static char_u *compile_cap_prog(synblock_T *synblock) /// Handle setting `winhighlight' in window "wp" static bool parse_winhl_opt(win_T *wp) { - int w_hl_id = 0, w_hl_id_inactive = 0; + int w_hl_id_normal = 0; + int w_hl_ids[HLF_COUNT] = { 0 }; + int hlf; const char *p = (const char *)wp->w_p_winhl; while (*p) { @@ -3596,18 +3598,25 @@ static bool parse_winhl_opt(win_T *wp) int hl_id = syn_check_group((char_u *)hi, (int)(commap-hi)); if (strncmp("Normal", p, nlen) == 0) { - w_hl_id = hl_id; - } else if (strncmp("NormalNC", p, nlen) == 0) { - w_hl_id_inactive = hl_id; + w_hl_id_normal = hl_id; } else { - return false; + for (hlf = 0; hlf < (int)HLF_COUNT; hlf++) { + if (strncmp(hlf_names[hlf], p, nlen) == 0) { + w_hl_ids[hlf] = hl_id; + break; + } + } + if (hlf == HLF_COUNT) { + return false; + } } p = *commap ? commap+1 : ""; } - wp->w_hl_id = w_hl_id; - wp->w_hl_id_inactive = w_hl_id_inactive; + wp->w_hl_id_normal = w_hl_id_normal; + memcpy(wp->w_hl_ids, w_hl_ids, sizeof(w_hl_ids)); + wp->w_hl_needs_update = true; return true; } @@ -4633,7 +4642,7 @@ get_option_value ( if ((int *)varp == &curbuf->b_changed) { *numval = curbufIsChanged(); } else { - *numval = *(int *)varp; + *numval = (long) *(int *)varp; // NOLINT(whitespace/cast) } } return 1; @@ -5169,9 +5178,13 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int e * CTRL-V or backslash */ if (valuep == &p_pt) { s = *valuep; - while (*s != NUL) - if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) + while (*s != NUL) { + if (put_escstr(fd, (char_u *)str2special((const char **)&s, false, + false), 2) + == FAIL) { return FAIL; + } + } } else if (expand) { buf = xmalloc(MAXPATHL); home_replace(NULL, *valuep, buf, MAXPATHL, FALSE); @@ -6167,15 +6180,16 @@ option_value2string ( } } else { // P_STRING varp = *(char_u **)(varp); - if (varp == NULL) /* just in case */ + if (varp == NULL) { // Just in case. NameBuff[0] = NUL; - else if (opp->flags & P_EXPAND) - home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); - /* Translate 'pastetoggle' into special key names */ - else if ((char_u **)opp->var == &p_pt) - str2specialbuf(p_pt, NameBuff, MAXPATHL); - else + } else if (opp->flags & P_EXPAND) { + home_replace(NULL, varp, NameBuff, MAXPATHL, false); + // Translate 'pastetoggle' into special key names. + } else if ((char_u **)opp->var == &p_pt) { + str2specialbuf((const char *)p_pt, (char *)NameBuff, MAXPATHL); + } else { STRLCPY(NameBuff, varp, MAXPATHL); + } } } |