summaryrefslogtreecommitdiff
path: root/src/popupmenu.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-23 21:01:34 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-23 21:01:34 +0200
commite0c03c8e107f109eadab145e18544d8e74a6976e (patch)
tree447b5b7477f4df9c2f4a7b69c9d579b52ff4183c /src/popupmenu.c
parenta6aa16423fdd0518ec9f3074b0d32b1d651d41e8 (diff)
downloadvim-git-e0c03c8e107f109eadab145e18544d8e74a6976e.tar.gz
patch 8.2.2803: flicker when the popup menu has an info popupv8.2.2803
Problem: Flicker when the popup menu has an info popup. Solution: Avoid drawing over the popup when it's going to be redrawn in the same position. (closes #8131) Also avoid redrawing the scrollbar.
Diffstat (limited to 'src/popupmenu.c')
-rw-r--r--src/popupmenu.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/popupmenu.c b/src/popupmenu.c
index 1f9840804..d2a73c0e0 100644
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -40,10 +40,6 @@ static int pum_win_width;
// makes pum_visible() return FALSE even when there is a popup menu.
static int pum_pretend_not_visible = FALSE;
-// When set the popup menu will redraw soon using the pum_win_ values. Do not
-// draw over the poup menu area to avoid flicker.
-static int pum_will_redraw = FALSE;
-
static int pum_set_selected(int n, int repeat);
#define PUM_DEF_HEIGHT 10
@@ -392,7 +388,7 @@ pum_under_menu(int row, int col)
&& row >= pum_row
&& row < pum_row + pum_height
&& col >= pum_col - 1
- && col < pum_col + pum_width;
+ && col < pum_col + pum_width + pum_scrollbar;
}
/*
@@ -1049,6 +1045,32 @@ pum_visible(void)
}
/*
+ * Return TRUE if the popup can be redrawn in the same position.
+ */
+ static int
+pum_in_same_position(void)
+{
+ return pum_window != curwin
+ || (pum_win_row == curwin->w_wrow + W_WINROW(curwin)
+ && pum_win_height == curwin->w_height
+ && pum_win_col == curwin->w_wincol
+ && pum_win_width == curwin->w_width);
+}
+
+/*
+ * Return TRUE when pum_may_redraw() will call pum_redraw().
+ * This means that the pum area should not be overwritten to avoid flicker.
+ */
+ int
+pum_redraw_in_same_position(void)
+{
+ if (!pum_visible() || pum_will_redraw)
+ return FALSE; // nothing to do
+
+ return pum_in_same_position();
+}
+
+/*
* Reposition the popup menu to adjust for window layout changes.
*/
void
@@ -1061,11 +1083,7 @@ pum_may_redraw(void)
if (!pum_visible() || pum_will_redraw)
return; // nothing to do
- if (pum_window != curwin
- || (pum_win_row == curwin->w_wrow + W_WINROW(curwin)
- && pum_win_height == curwin->w_height
- && pum_win_col == curwin->w_wincol
- && pum_win_width == curwin->w_width))
+ if (pum_in_same_position())
{
// window position didn't change, redraw in the same position
pum_redraw();