Skip to content

Commit 714cbe5

Browse files
committed
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)
1 parent c4390fe commit 714cbe5

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/popupmenu.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ pum_display(
361361
// redo the positioning. Limit this to two times, when there is not
362362
// much room the window size will keep changing.
363363
} while (pum_set_selected(selected, redo_count) && ++redo_count <= 2);
364+
365+
pum_redraw();
364366
}
365367

366368
/*
@@ -541,8 +543,23 @@ pum_redraw(void)
541543
{
542544
if (st != NULL)
543545
{
544-
screen_puts_len(st, (int)STRLEN(st), row, col,
545-
attr);
546+
int size = (int)STRLEN(st);
547+
int cells = (*mb_string2cells)(st, size);
548+
549+
// only draw the text that fits
550+
while (size > 0
551+
&& col + cells > pum_width + pum_col)
552+
{
553+
--size;
554+
if (has_mbyte)
555+
{
556+
size -= (*mb_head_off)(st, st + size);
557+
cells -= (*mb_ptr2cells)(st + size);
558+
}
559+
else
560+
--cells;
561+
}
562+
screen_puts_len(st, size, row, col, attr);
546563
vim_free(st);
547564
}
548565
col += width;
@@ -990,9 +1007,6 @@ pum_set_selected(int n, int repeat UNUSED)
9901007
popup_hide_info();
9911008
#endif
9921009

993-
if (!resized)
994-
pum_redraw();
995-
9961010
return resized;
9971011
}
9981012

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1995,
753755
/**/
754756
1994,
755757
/**/

0 commit comments

Comments
 (0)