Mercurial > vim
changeset 22896:6145a1232c3a v8.2.1995
patch 8.2.1995: the popup menu can cause too much redrawing
Commit: https://github.com/vim/vim/commit/714cbe5b212abbecb578b90424d89f47142e8f25
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 16 19:12:00 2020 +0100
patch 8.2.1995: the popup menu can cause too much redrawing
Problem: The popup menu can cause too much redrawing.
Solution: Reduce the length of the displayed text. (Yasuhiro Matsumoto,
closes #7306)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Nov 2020 19:15:03 +0100 |
parents | 040778b130ee |
children | 09b160140ca3 |
files | src/popupmenu.c src/version.c |
diffstat | 2 files changed, 21 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/popupmenu.c +++ b/src/popupmenu.c @@ -361,6 +361,8 @@ pum_display( // redo the positioning. Limit this to two times, when there is not // much room the window size will keep changing. } while (pum_set_selected(selected, redo_count) && ++redo_count <= 2); + + pum_redraw(); } /* @@ -541,8 +543,23 @@ pum_redraw(void) { if (st != NULL) { - screen_puts_len(st, (int)STRLEN(st), row, col, - attr); + int size = (int)STRLEN(st); + int cells = (*mb_string2cells)(st, size); + + // only draw the text that fits + while (size > 0 + && col + cells > pum_width + pum_col) + { + --size; + if (has_mbyte) + { + size -= (*mb_head_off)(st, st + size); + cells -= (*mb_ptr2cells)(st + size); + } + else + --cells; + } + screen_puts_len(st, size, row, col, attr); vim_free(st); } col += width; @@ -990,9 +1007,6 @@ pum_set_selected(int n, int repeat UNUSE popup_hide_info(); #endif - if (!resized) - pum_redraw(); - return resized; }