From 7193323b7796c05573f3aa89d422e848feb3a8dc Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Fri, 20 Jan 2023 16:00:55 +0000 Subject: patch 9.0.1223: cannot use setcellwidths() below 0x100 Problem: Cannot use setcellwidths() below 0x100. Solution: Also accept characters between 0x80 and 0x100. (Ken Takata, closes #11834) --- src/mbyte.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/mbyte.c') diff --git a/src/mbyte.c b/src/mbyte.c index 6d7137ed55..57aa619990 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -1589,19 +1589,26 @@ utf_char2cells(int c) #endif }; - if (c >= 0x100) - { -#if defined(FEAT_EVAL) || defined(USE_WCHAR_FUNCTIONS) - int n; -#endif - #ifdef FEAT_EVAL - n = cw_value(c); + // Use the value from setcellwidths() at 0x80 and higher, unless the + // character is not printable. + if (c >= 0x80 && +# ifdef USE_WCHAR_FUNCTIONS + wcwidth(c) >= 1 && +# endif + vim_isprintc(c)) + { + int n = cw_value(c); if (n != 0) return n; + } #endif + if (c >= 0x100) + { #ifdef USE_WCHAR_FUNCTIONS + int n; + /* * Assume the library function wcwidth() works better than our own * stuff. It should return 1 for ambiguous width chars! @@ -5661,9 +5668,9 @@ f_setcellwidths(typval_T *argvars, typval_T *rettv UNUSED) if (i == 0) { n1 = lili->li_tv.vval.v_number; - if (n1 < 0x100) + if (n1 < 0x80) { - emsg(_(e_only_values_of_0x100_and_higher_supported)); + emsg(_(e_only_values_of_0x80_and_higher_supported)); vim_free(ptrs); return; } -- cgit v1.2.3