mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user