patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Problem: setcellwidths() may make 'listchars' or 'fillchars' invalid.
Solution: Check the value and give an error. (closes #9024)
diff --git a/src/mbyte.c b/src/mbyte.c
index a626f50..76eab4e 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -5510,6 +5510,8 @@
int i;
listitem_T **ptrs;
cw_interval_T *table;
+ cw_interval_T *cw_table_save;
+ size_t cw_table_size_save;
if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
return;
@@ -5620,9 +5622,41 @@
}
vim_free(ptrs);
- vim_free(cw_table);
+
+ cw_table_save = cw_table;
+ cw_table_size_save = cw_table_size;
cw_table = table;
cw_table_size = l->lv_len;
+
+ // Check that the new value does not conflict with 'fillchars' or
+ // 'listchars'.
+ if (set_chars_option(curwin, &p_fcs) != NULL)
+ {
+ emsg(_(e_conflicts_with_value_of_fillchars));
+ cw_table = cw_table_save;
+ cw_table_size = cw_table_size_save;
+ vim_free(table);
+ return;
+ }
+ else
+ {
+ tabpage_T *tp;
+ win_T *wp;
+
+ FOR_ALL_TAB_WINDOWS(tp, wp)
+ {
+ if (set_chars_option(wp, &wp->w_p_lcs) != NULL)
+ {
+ emsg((e_conflicts_with_value_of_listchars));
+ cw_table = cw_table_save;
+ cw_table_size = cw_table_size_save;
+ vim_free(table);
+ return;
+ }
+ }
+ }
+
+ vim_free(cw_table_save);
}
void