forked from aniani/vim
patch 9.1.1306: completion menu rendering can be improved
Problem: Parts of the popup menu were rendered twice when the popup was at maximum width because the truncation flag was being set too liberally. Solution: Make the truncation condition more precise by only setting it when there's exactly one character of space remaining (glepnir). closes: #17108 Signed-off-by: glepnir <glephunter@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
cf7f01252f
commit
32f2bb6e1e
@ -691,6 +691,10 @@ pum_redraw(void)
|
|||||||
width = 0;
|
width = 0;
|
||||||
s = NULL;
|
s = NULL;
|
||||||
p = pum_get_item(idx, item_type);
|
p = pum_get_item(idx, item_type);
|
||||||
|
|
||||||
|
if (j + 1 < 3)
|
||||||
|
next_isempty = pum_get_item(idx, order[j + 1]) == NULL;
|
||||||
|
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
for ( ; ; MB_PTR_ADV(p))
|
for ( ; ; MB_PTR_ADV(p))
|
||||||
{
|
{
|
||||||
@ -731,15 +735,13 @@ pum_redraw(void)
|
|||||||
int cells;
|
int cells;
|
||||||
int over_cell = 0;
|
int over_cell = 0;
|
||||||
int truncated = FALSE;
|
int truncated = FALSE;
|
||||||
|
int pad = next_isempty ? 0 : 2;
|
||||||
|
|
||||||
cells = mb_string2cells(rt , -1);
|
cells = mb_string2cells(rt , -1);
|
||||||
truncated = pum_width == p_pmw
|
truncated = pum_width == p_pmw
|
||||||
&& pum_width - totwidth < cells;
|
&& pum_width - totwidth < cells + pad;
|
||||||
|
|
||||||
if (pum_width == p_pmw && !truncated
|
|
||||||
&& (j + 1 < 3 && pum_get_item(idx, order[j + 1]) != NULL))
|
|
||||||
truncated = TRUE;
|
|
||||||
|
|
||||||
|
// only draw the text that fits
|
||||||
if (cells > pum_width)
|
if (cells > pum_width)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
@ -816,12 +818,9 @@ pum_redraw(void)
|
|||||||
int cells = (*mb_string2cells)(st, size);
|
int cells = (*mb_string2cells)(st, size);
|
||||||
char_u *st_end = NULL;
|
char_u *st_end = NULL;
|
||||||
int over_cell = 0;
|
int over_cell = 0;
|
||||||
|
int pad = next_isempty ? 0 : 2;
|
||||||
int truncated = pum_width == p_pmw
|
int truncated = pum_width == p_pmw
|
||||||
&& pum_width - totwidth < cells;
|
&& pum_width - totwidth < cells + pad;
|
||||||
|
|
||||||
if (pum_width == p_pmw && !truncated
|
|
||||||
&& (j + 1 < 3 && pum_get_item(idx, order[j + 1]) != NULL))
|
|
||||||
truncated = TRUE;
|
|
||||||
|
|
||||||
// only draw the text that fits
|
// only draw the text that fits
|
||||||
while (size > 0
|
while (size > 0
|
||||||
@ -910,9 +909,6 @@ pum_redraw(void)
|
|||||||
else
|
else
|
||||||
n = order[j] == CPT_ABBR ? 1 : 0;
|
n = order[j] == CPT_ABBR ? 1 : 0;
|
||||||
|
|
||||||
if (j + 1 < 3)
|
|
||||||
next_isempty = pum_get_item(idx, order[j + 1]) == NULL;
|
|
||||||
|
|
||||||
// Stop when there is nothing more to display.
|
// Stop when there is nothing more to display.
|
||||||
if (j == 2
|
if (j == 2
|
||||||
|| (next_isempty && (j == 1 || (j == 0
|
|| (next_isempty && (j == 1 || (j == 0
|
||||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1306,
|
||||||
/**/
|
/**/
|
||||||
1305,
|
1305,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user