From ac1c5ccb2c04177b526e0aa2ed286760fad98a5d Mon Sep 17 00:00:00 2001 From: glepnir Date: Thu, 27 Feb 2025 18:41:29 +0800 Subject: fix(popup): reuse pum preview float win, set 'winfixbuf' #32636 Problem: popup floating window is closed and recreated for each item selection, this is a bit wasteful. Solution: - Hide the preview win (instead of closing it) when the menu is still displayed: 1. When selected_item is -1. 2. When switching from an item with an "info" field to one without. - When pum is undisplayed it is still closed. --- src/nvim/popupmenu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim') diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index d1c6f647fd..2e533bea23 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -871,6 +871,7 @@ win_T *pum_set_info(int selected, char *info) if (!wp) { return NULL; } + wp->w_p_wfb = true; } linenr_T lnum = 0; int max_info_width = 0; @@ -915,7 +916,8 @@ static bool pum_set_selected(int n, int repeat) if (use_float && (pum_selected < 0 || pum_array[pum_selected].pum_info == NULL)) { win_T *wp = win_float_find_preview(); if (wp) { - win_close(wp, true, true); + wp->w_config.hide = true; + win_config_float(wp, wp->w_config); } } -- cgit