vim-patch:9.1.1257: Mixing vim_strsize() with mb_ptr2cells() in pum_redraw()

Problem:  Mixing vim_strsize() with mb_ptr2cells() in pum_redraw().
Solution: Change vim_strsize() to mb_string2cells() (zeertzjq).

Since vim_strsize() uses ptr2cells() for the cell width of each char, it
is strange to mix it with mb_ptr2cells(), which is used both just below
and in pum_screen_puts_with_attr(), and screen_puts_len() also uses
something similar.  Meanwhile mb_string2cells() uses mb_ptr2cells() for
the cell width of each char.

Note that the vim_strsize() and mb_string2cells() actually return the
same value here, as the transstr() above makes sure the string only
contains printable chars, and ptr2cells() and mb_ptr2cells() only return
different values for unprintable chars.

closes: vim/vim#17003

90e52490b3
This commit is contained in:
zeertzjq
2025-03-29 20:12:12 +08:00
parent 686e7aca40
commit 52b19e0124

View File

@@ -710,7 +710,7 @@ void pum_redraw(void)
if (pum_rl) { if (pum_rl) {
char *rt = reverse_text(st); char *rt = reverse_text(st);
char *rt_start = rt; char *rt_start = rt;
int cells = vim_strsize(rt); int cells = (int)mb_string2cells(rt);
if (p_pmw > ellipsis_width && pum_width == p_pmw if (p_pmw > ellipsis_width && pum_width == p_pmw
&& grid_col - cells < col_off - pum_width) { && grid_col - cells < col_off - pum_width) {
need_ellipsis = true; need_ellipsis = true;