aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/popupmnu.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-20 12:14:35 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2019-02-02 16:31:49 +0100
commit2c01e79dc47ff83e0af118fb3fee50fa2ff7fcf2 (patch)
tree05b26da49d8e3a6d50ce911de5ed8395a4c444c3 /src/nvim/popupmnu.c
parent31cbd34d9724922026a5ae00846ce8105605df5d (diff)
downloadrneovim-2c01e79dc47ff83e0af118fb3fee50fa2ff7fcf2.tar.gz
rneovim-2c01e79dc47ff83e0af118fb3fee50fa2ff7fcf2.tar.bz2
rneovim-2c01e79dc47ff83e0af118fb3fee50fa2ff7fcf2.zip
Reduce pum redraws from edit.c by delaying undisplay of pum
This makes it possible for the compositor to compare the old pum with the new position, and only clear what is necessary.
Diffstat (limited to 'src/nvim/popupmnu.c')
-rw-r--r--src/nvim/popupmnu.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c
index 86cb66c6f3..78b64621e9 100644
--- a/src/nvim/popupmnu.c
+++ b/src/nvim/popupmnu.c
@@ -42,6 +42,7 @@ static int pum_row; // top row of pum
static int pum_col; // left column of pum
static bool pum_is_visible = false;
+static bool pum_is_drawn = false;
static bool pum_external = false;
static ScreenGrid pum_grid = SCREEN_GRID_INIT;
@@ -88,6 +89,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed)
// Mark the pum as visible already here,
// to avoid that must_redraw is set when 'cursorcolumn' is on.
pum_is_visible = true;
+ pum_is_drawn = true;
validate_cursor_col();
above_row = 0;
below_row = cmdline_row;
@@ -730,6 +732,8 @@ static int pum_set_selected(int n, int repeat)
// Update the screen before drawing the popup menu.
// Enable updating the status lines.
+ // TODO(bfredl): can simplify, get rid of the flag munging?
+ // or at least eliminate extra redraw before win_enter()?
pum_is_visible = false;
update_screen(0);
pum_is_visible = true;
@@ -759,17 +763,27 @@ static int pum_set_selected(int n, int repeat)
}
/// Undisplay the popup menu (later).
-void pum_undisplay(void)
+void pum_undisplay(bool immediate)
{
pum_is_visible = false;
pum_array = NULL;
- if (pum_external) {
- ui_call_popupmenu_hide();
- } else {
- ui_comp_remove_grid(&pum_grid);
- // TODO(bfredl): consider the possibility of keeping float grids allocated.
- grid_free(&pum_grid);
+ if (immediate) {
+ pum_check_clear();
+ }
+}
+
+void pum_check_clear(void)
+{
+ if (!pum_is_visible && pum_is_drawn) {
+ if (pum_external) {
+ ui_call_popupmenu_hide();
+ } else {
+ ui_comp_remove_grid(&pum_grid);
+ // TODO(bfredl): consider keeping float grids allocated.
+ grid_free(&pum_grid);
+ }
+ pum_is_drawn = false;
}
}