]> granicus.if.org Git - vim/commitdiff
patch 8.2.1995: the popup menu can cause too much redrawing v8.2.1995
authorBram Moolenaar <Bram@vim.org>
Mon, 16 Nov 2020 18:12:00 +0000 (19:12 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 16 Nov 2020 18:12:00 +0000 (19:12 +0100)
Problem:    The popup menu can cause too much redrawing.
Solution:   Reduce the length of the displayed text. (Yasuhiro Matsumoto,
            closes #7306)

src/popupmenu.c
src/version.c

index 8033d7211177abbbb247db74352490ff774ff4c8..f4f210b5d7a89edd397c02cfb120d6c06949481c 100644 (file)
@@ -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;
 }
 
index 8418d98d2c39b13b572ca050e713ab2dee756474..8de530879776b0b41b5ec191fdbbb20202d0ba3b 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1995,
 /**/
     1994,
 /**/