From e6d35b9e4011023a4efd06234fe2fd2c5f7dc829 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Dec 2021 08:06:27 +0800 Subject: fix(pum_redraw): use grid_puts_len() to truncate the text Nvim already resizes grid to the required width, so there is no need to truncate the text in pum_redraw(). What's more, truncation is currently done incorrectly because Vim patch 8.2.1995 was ported incorrectly. This nearly reverts the truncation part of Vim patch 8.2.1995, but not the part that reduces unnecessary calls to pum_redraw(). The original PR https://github.com/vim/vim/pull/7306 didn't explain much about which part of it actually reduces redraws. --- src/nvim/popupmnu.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index 606c03f838..b253077844 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -542,17 +542,8 @@ void pum_redraw(void) xfree(st); col -= width; } else { - int size = (int)STRLEN(st); - int cells = (int)mb_string2cells(st); - - // only draw the text that fits - while (size > 0 && col + cells > pum_width + pum_col) { - size--; - size -= utf_head_off(st, st + size); - cells -= utf_ptr2cells(st + size); - } - - grid_puts_len(&pum_grid, st, size, row, col, attr); + // use grid_puts_len() to truncate the text + grid_puts(&pum_grid, st, row, col, attr); xfree(st); col += width; } -- cgit