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.
This commit is contained in:
glepnir
2025-02-27 18:41:29 +08:00
committed by GitHub
parent 6a9555c0fa
commit ac1c5ccb2c
2 changed files with 138 additions and 49 deletions

View File

@@ -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);
}
}