diff src/popupwin.c @ 17506:74b6674b99fd v8.1.1751

patch 8.1.1751: when redrawing popups plines_win() may be called often commit https://github.com/vim/vim/commit/9d5ffceb3fea247a88d4d3936e97b7f488aab6ff Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 26 21:01:29 2019 +0200 patch 8.1.1751: when redrawing popups plines_win() may be called often Problem: When redrawing popups plines_win() may be called often. Solution: Pass a cache to mouse_comp_pos().
author Bram Moolenaar <Bram@vim.org>
date Fri, 26 Jul 2019 21:15:06 +0200
parents 57b9fca8c7d2
children 34966be2e856
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2593,6 +2593,10 @@ may_update_popup_mask(int type)
     // Only check which lines are to be updated if not already
     // updating all lines.
     if (mask == popup_mask_next)
+    {
+	int	    *plines_cache = ALLOC_CLEAR_MULT(int, Rows);
+	win_T	    *prev_wp = NULL;
+
 	for (line = 0; line < screen_Rows; ++line)
 	{
 	    int	    col_done = 0;
@@ -2625,13 +2629,19 @@ may_update_popup_mask(int type)
 			wp = mouse_find_win(&line_cp, &col_cp, IGNORE_POPUP);
 			if (wp != NULL)
 			{
+			    if (wp != prev_wp)
+			    {
+				vim_memset(plines_cache, 0, sizeof(int) * Rows);
+				prev_wp = wp;
+			    }
+
 			    if (line_cp >= wp->w_height)
 				// In (or below) status line
 				wp->w_redr_status = TRUE;
 			    // compute the position in the buffer line from the
 			    // position on the screen
 			    else if (mouse_comp_pos(wp, &line_cp, &col_cp,
-									&lnum))
+							  &lnum, plines_cache))
 				// past bottom
 				wp->w_redr_status = TRUE;
 			    else
@@ -2645,6 +2655,9 @@ may_update_popup_mask(int type)
 		}
 	    }
 	}
+
+	vim_free(plines_cache);
+    }
 }
 
 /*