comparison src/optionstr.c @ 34157:e7d64a3fffe4 v9.1.0039

patch 9.1.0039: too vague errors for 'listchars'/'fillchars' Commit: https://github.com/vim/vim/commit/6a8d2e1634f8f0d7463a2786dbcbe0f38dd287a7 Author: zeertzjq <zeertzjq@outlook.com> Date: Wed Jan 17 20:54:49 2024 +0100 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>
author Christian Brabandt <cb@256bit.org>
date Wed, 17 Jan 2024 21:15:03 +0100
parents 170e917524f7
children a7354a835a78
comparison
equal deleted inserted replaced
34156:6e58c97e633a 34157:e7d64a3fffe4
231 static char * 231 static char *
232 illegal_char(char *errbuf, size_t errbuflen, int c) 232 illegal_char(char *errbuf, size_t errbuflen, int c)
233 { 233 {
234 if (errbuf == NULL) 234 if (errbuf == NULL)
235 return ""; 235 return "";
236 vim_snprintf((char *)errbuf, errbuflen, _(e_illegal_character_str), 236 vim_snprintf(errbuf, errbuflen, _(e_illegal_character_str),
237 (char *)transchar(c)); 237 (char *)transchar(c));
238 return errbuf; 238 return errbuf;
239 } 239 }
240 240
241 /* 241 /*
1348 1348
1349 /* 1349 /*
1350 * The global 'listchars' or 'fillchars' option is changed. 1350 * The global 'listchars' or 'fillchars' option is changed.
1351 */ 1351 */
1352 static char * 1352 static char *
1353 did_set_global_listfillchars(char_u *val, int opt_lcs, int opt_flags) 1353 did_set_global_listfillchars(char_u *val, int opt_lcs, int opt_flags,
1354 char *errbuf, size_t errbuflen)
1354 { 1355 {
1355 char *errmsg = NULL; 1356 char *errmsg = NULL;
1356 char_u **local_ptr = opt_lcs ? &curwin->w_p_lcs : &curwin->w_p_fcs; 1357 char_u **local_ptr = opt_lcs ? &curwin->w_p_lcs : &curwin->w_p_fcs;
1357 1358
1358 // only apply the global value to "curwin" when it does not have a 1359 // only apply the global value to "curwin" when it does not have a
1359 // local value 1360 // local value
1360 if (opt_lcs) 1361 if (opt_lcs)
1361 errmsg = set_listchars_option(curwin, val, 1362 errmsg = set_listchars_option(curwin, val,
1362 **local_ptr == NUL || !(opt_flags & OPT_GLOBAL)); 1363 **local_ptr == NUL || !(opt_flags & OPT_GLOBAL),
1364 errbuf, errbuflen);
1363 else 1365 else
1364 errmsg = set_fillchars_option(curwin, val, 1366 errmsg = set_fillchars_option(curwin, val,
1365 **local_ptr == NUL || !(opt_flags & OPT_GLOBAL)); 1367 **local_ptr == NUL || !(opt_flags & OPT_GLOBAL),
1368 errbuf, errbuflen);
1366 if (errmsg != NULL) 1369 if (errmsg != NULL)
1367 return errmsg; 1370 return errmsg;
1368 1371
1369 tabpage_T *tp; 1372 tabpage_T *tp;
1370 win_T *wp; 1373 win_T *wp;
1380 // If no error was returned above, we don't expect an error 1383 // If no error was returned above, we don't expect an error
1381 // here, so ignore the return value. 1384 // here, so ignore the return value.
1382 if (opt_lcs) 1385 if (opt_lcs)
1383 { 1386 {
1384 if (*wp->w_p_lcs == NUL) 1387 if (*wp->w_p_lcs == NUL)
1385 (void)set_listchars_option(wp, wp->w_p_lcs, TRUE); 1388 (void)set_listchars_option(wp, wp->w_p_lcs, TRUE, NULL, 0);
1386 } 1389 }
1387 else 1390 else
1388 { 1391 {
1389 if (*wp->w_p_fcs == NUL) 1392 if (*wp->w_p_fcs == NUL)
1390 (void)set_fillchars_option(wp, wp->w_p_fcs, TRUE); 1393 (void)set_fillchars_option(wp, wp->w_p_fcs, TRUE, NULL, 0);
1391 } 1394 }
1392 } 1395 }
1393 1396
1394 redraw_all_later(UPD_NOT_VALID); 1397 redraw_all_later(UPD_NOT_VALID);
1395 1398
1406 char *errmsg = NULL; 1409 char *errmsg = NULL;
1407 1410
1408 if ( varp == &p_lcs // global 'listchars' 1411 if ( varp == &p_lcs // global 'listchars'
1409 || varp == &p_fcs) // global 'fillchars' 1412 || varp == &p_fcs) // global 'fillchars'
1410 errmsg = did_set_global_listfillchars(*varp, varp == &p_lcs, 1413 errmsg = did_set_global_listfillchars(*varp, varp == &p_lcs,
1411 args->os_flags); 1414 args->os_flags, args->os_errbuf, args->os_errbuflen);
1412 else if (varp == &curwin->w_p_lcs) // local 'listchars' 1415 else if (varp == &curwin->w_p_lcs) // local 'listchars'
1413 errmsg = set_listchars_option(curwin, *varp, TRUE); 1416 errmsg = set_listchars_option(curwin, *varp, TRUE,
1417 args->os_errbuf, args->os_errbuflen);
1414 else if (varp == &curwin->w_p_fcs) // local 'fillchars' 1418 else if (varp == &curwin->w_p_fcs) // local 'fillchars'
1415 errmsg = set_fillchars_option(curwin, *varp, TRUE); 1419 errmsg = set_fillchars_option(curwin, *varp, TRUE,
1420 args->os_errbuf, args->os_errbuflen);
1416 1421
1417 return errmsg; 1422 return errmsg;
1418 } 1423 }
1419 1424
1420 /* 1425 /*