summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-16 19:12:00 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-16 19:12:00 +0100
commit714cbe5b212abbecb578b90424d89f47142e8f25 (patch)
treeeedf0d7d8985a00562a3e44f3c16933e7b17f619
parentc4390fe6c0d1b47b1acd373d7e8ef986412c0600 (diff)
patch 8.2.1995: the popup menu can cause too much redrawingv8.2.1995
Problem: The popup menu can cause too much redrawing. Solution: Reduce the length of the displayed text. (Yasuhiro Matsumoto, closes #7306)
-rw-r--r--src/popupmenu.c24
-rw-r--r--src/version.c2
2 files changed, 21 insertions, 5 deletions
diff --git a/src/popupmenu.c b/src/popupmenu.c
index 8033d72111..f4f210b5d7 100644
--- 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 UNUSED)
popup_hide_info();
#endif
- if (!resized)
- pum_redraw();
-
return resized;
}
diff --git a/src/version.c b/src/version.c
index 8418d98d2c..8de5308797 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1995,
+/**/
1994,
/**/
1993,