0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.1.0039: too vague errors for 'listchars'/'fillchars'

Problem:  too vague errors for 'listchars'/'fillchars'
Solution: Include the field name in error message.
          (zeertzjq)

related: neovim/neovim#27050
closes: #13877

Co-authored-by: Cole Frankenhoff <cole.nhf@gmail.com>
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-01-17 20:54:49 +01:00
committed by Christian Brabandt
parent 4ea37f88e8
commit 6a8d2e1634
10 changed files with 140 additions and 91 deletions

View File

@@ -233,7 +233,7 @@ illegal_char(char *errbuf, size_t errbuflen, int c)
{
if (errbuf == NULL)
return "";
vim_snprintf((char *)errbuf, errbuflen, _(e_illegal_character_str),
vim_snprintf(errbuf, errbuflen, _(e_illegal_character_str),
(char *)transchar(c));
return errbuf;
}
@@ -1350,7 +1350,8 @@ expand_set_clipboard(optexpand_T *args, int *numMatches, char_u ***matches)
* The global 'listchars' or 'fillchars' option is changed.
*/
static char *
did_set_global_listfillchars(char_u *val, int opt_lcs, int opt_flags)
did_set_global_listfillchars(char_u *val, int opt_lcs, int opt_flags,
char *errbuf, size_t errbuflen)
{
char *errmsg = NULL;
char_u **local_ptr = opt_lcs ? &curwin->w_p_lcs : &curwin->w_p_fcs;
@@ -1359,10 +1360,12 @@ did_set_global_listfillchars(char_u *val, int opt_lcs, int opt_flags)
// local value
if (opt_lcs)
errmsg = set_listchars_option(curwin, val,
**local_ptr == NUL || !(opt_flags & OPT_GLOBAL));
**local_ptr == NUL || !(opt_flags & OPT_GLOBAL),
errbuf, errbuflen);
else
errmsg = set_fillchars_option(curwin, val,
**local_ptr == NUL || !(opt_flags & OPT_GLOBAL));
**local_ptr == NUL || !(opt_flags & OPT_GLOBAL),
errbuf, errbuflen);
if (errmsg != NULL)
return errmsg;
@@ -1382,12 +1385,12 @@ did_set_global_listfillchars(char_u *val, int opt_lcs, int opt_flags)
if (opt_lcs)
{
if (*wp->w_p_lcs == NUL)
(void)set_listchars_option(wp, wp->w_p_lcs, TRUE);
(void)set_listchars_option(wp, wp->w_p_lcs, TRUE, NULL, 0);
}
else
{
if (*wp->w_p_fcs == NUL)
(void)set_fillchars_option(wp, wp->w_p_fcs, TRUE);
(void)set_fillchars_option(wp, wp->w_p_fcs, TRUE, NULL, 0);
}
}
@@ -1408,11 +1411,13 @@ did_set_chars_option(optset_T *args)
if ( varp == &p_lcs // global 'listchars'
|| varp == &p_fcs) // global 'fillchars'
errmsg = did_set_global_listfillchars(*varp, varp == &p_lcs,
args->os_flags);
args->os_flags, args->os_errbuf, args->os_errbuflen);
else if (varp == &curwin->w_p_lcs) // local 'listchars'
errmsg = set_listchars_option(curwin, *varp, TRUE);
errmsg = set_listchars_option(curwin, *varp, TRUE,
args->os_errbuf, args->os_errbuflen);
else if (varp == &curwin->w_p_fcs) // local 'fillchars'
errmsg = set_fillchars_option(curwin, *varp, TRUE);
errmsg = set_fillchars_option(curwin, *varp, TRUE,
args->os_errbuf, args->os_errbuflen);
return errmsg;
}